Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Generated Connector Code and Documentation #2

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
87c920b
ballerina code generation using Open API tool + testing
ParameswaranSajeenthiran Dec 19, 2024
4fdf520
added readme(initial draft)
ParameswaranSajeenthiran Dec 19, 2024
6f00c4d
added docs/setup/resources
ParameswaranSajeenthiran Dec 19, 2024
9c4c2c2
Update README.md
ParameswaranSajeenthiran Dec 19, 2024
17c49ab
updated git ignore
ParameswaranSajeenthiran Dec 19, 2024
e982ef0
revert .gitignore
ParameswaranSajeenthiran Dec 19, 2024
94cd4b1
aaded Config.toml.template
ParameswaranSajeenthiran Dec 20, 2024
806fa1b
removed unwanted file (token.txt)
ParameswaranSajeenthiran Dec 20, 2024
a56e8d8
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Dec 20, 2024
2a1dab2
[Automated] Update the toml files
ParameswaranSajeenthiran Dec 20, 2024
acbce5b
review changes implemented
ParameswaranSajeenthiran Dec 20, 2024
4f6f77a
updated suggested naming for client
ParameswaranSajeenthiran Dec 20, 2024
f3a1c92
updated readme package.md and module.md
ParameswaranSajeenthiran Dec 20, 2024
fcca35d
review changes + readme, package.md module.md update
ParameswaranSajeenthiran Dec 20, 2024
451274f
added examples
ParameswaranSajeenthiran Dec 20, 2024
c347662
updated readme
ParameswaranSajeenthiran Jan 2, 2025
a9cd92e
implemention + testing of examples
ParameswaranSajeenthiran Jan 2, 2025
c61fd61
code cleaning and formatting
ParameswaranSajeenthiran Jan 2, 2025
16b28af
added sanitization for shortening the api resource path
ParameswaranSajeenthiran Jan 2, 2025
fd55d67
updated readme intro
ParameswaranSajeenthiran Jan 2, 2025
a669330
review changes implemented
ParameswaranSajeenthiran Jan 3, 2025
6b8e879
updated to generic return type in callback example
ParameswaranSajeenthiran Jan 3, 2025
0a19ecc
removed double quotes
ParameswaranSajeenthiran Jan 3, 2025
31dad3b
updated return type of delete in extension-crud example
ParameswaranSajeenthiran Jan 3, 2025
681c292
readme file review changes implemented
ParameswaranSajeenthiran Jan 6, 2025
3ba3eac
git ignore updated
ParameswaranSajeenthiran Jan 6, 2025
08d6473
[Automated] Update the toml files
ParameswaranSajeenthiran Jan 7, 2025
ae2ed07
updated license.txt and re-generated client
ParameswaranSajeenthiran Jan 7, 2025
f0636ff
updated org in examples Ballerina.toml to wso2
ParameswaranSajeenthiran Jan 7, 2025
908483b
added license header in test and example files
ParameswaranSajeenthiran Jan 7, 2025
1849b94
updated order of import according to the convenction of bal import
ParameswaranSajeenthiran Jan 7, 2025
ec153d4
Update README.md
ParameswaranSajeenthiran Jan 7, 2025
6248277
Update README.md
ParameswaranSajeenthiran Jan 8, 2025
cbf7e98
update img uri in readme
ParameswaranSajeenthiran Jan 8, 2025
dd05d34
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 8, 2025
8c12974
Update Module.md
ParameswaranSajeenthiran Jan 8, 2025
a069c46
Update Module.md
ParameswaranSajeenthiran Jan 8, 2025
03a5fac
Update Package.md
ParameswaranSajeenthiran Jan 8, 2025
482b143
Update README.md
ParameswaranSajeenthiran Jan 8, 2025
9d12139
Update README.md
ParameswaranSajeenthiran Jan 8, 2025
cf4516d
Update README.md
ParameswaranSajeenthiran Jan 8, 2025
fe92f88
readme , package and module developer account creation para update
ParameswaranSajeenthiran Jan 8, 2025
fcea252
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 8, 2025
f1d3b99
updated readme with v4
ParameswaranSajeenthiran Jan 9, 2025
27889f6
added icon
ParameswaranSajeenthiran Jan 9, 2025
d756bd2
Update README.md with the exact uri for the examples link
ParameswaranSajeenthiran Jan 9, 2025
26c77de
Update Package.md with exact examples uri
ParameswaranSajeenthiran Jan 9, 2025
00ba00c
Update Module.md with exact example uri
ParameswaranSajeenthiran Jan 9, 2025
72106aa
Update README.md with exact img path
ParameswaranSajeenthiran Jan 9, 2025
ebdac0d
Update Module.md with img absolute path
ParameswaranSajeenthiran Jan 9, 2025
1bd8bb8
Update Package.md with img absolute path
ParameswaranSajeenthiran Jan 9, 2025
55bf4a7
updated readme with no backticks
ParameswaranSajeenthiran Jan 9, 2025
456ada9
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 9, 2025
94a56fa
[Automated] Update the toml files
ParameswaranSajeenthiran Jan 9, 2025
60cfce1
assert entire payload
ParameswaranSajeenthiran Jan 9, 2025
a10ed62
removed extra line and io
ParameswaranSajeenthiran Jan 9, 2025
298e297
[Automated] Update the toml files
ParameswaranSajeenthiran Jan 9, 2025
476df56
Update README.md
ParameswaranSajeenthiran Jan 9, 2025
4d3498f
Update README.md
ParameswaranSajeenthiran Jan 9, 2025
06e0334
Update examples/callback-completion/main.bal
ParameswaranSajeenthiran Jan 9, 2025
dabfa11
added example readme files
ParameswaranSajeenthiran Jan 9, 2025
49606d6
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 9, 2025
6c47b4a
Update README.md
ParameswaranSajeenthiran Jan 9, 2025
8437138
Update README.md
ParameswaranSajeenthiran Jan 9, 2025
e0a1b22
delete unwanted file
ParameswaranSajeenthiran Jan 10, 2025
8d89546
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 10, 2025
a1d35a7
Delete ballerina/tests/mock_service.bal
ParameswaranSajeenthiran Jan 10, 2025
b8ae3e9
Update mockService.bal
ParameswaranSajeenthiran Jan 10, 2025
8290d8b
Update Ballerina.toml of CRUD example
ParameswaranSajeenthiran Jan 10, 2025
37467a8
Update Ballerina.toml of callback example
ParameswaranSajeenthiran Jan 10, 2025
82f73a2
seperated mock tests
ParameswaranSajeenthiran Jan 10, 2025
4cb24cf
Merge branch 'main' of https://github.com/ParameswaranSajeenthiran/mo…
ParameswaranSajeenthiran Jan 10, 2025
8f66a7f
rename the readme file
ParameswaranSajeenthiran Jan 10, 2025
8646e58
removed unused http import
ParameswaranSajeenthiran Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ build

# Ignore Docker env file
docker.env

# Ignore Roup
.roup
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved
213 changes: 207 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,222 @@

## Overview

[//]: # (TODO: Add overview mentioning the purpose of the module, supported REST API versions, and other high-level details.)

[HubSpot ](https://www.hubspot.com/) is an AI-powered customer relationship management (CRM) platform.

The `ballerinax/hubspot.automation.actions` offers APIs to connect and interact with the [Automation Actions](https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions) endpoints , specifically based on the [API v4 documention](https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions)
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved






ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

The `hubspot.automation.actions` package offers APIs to connect and interact with [Hubpsot Automation action API (v4)](https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions) endpoints.
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the Hubspot Automation action API connector in Ballerina, you must have a HubSpot developer account.
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

### Step 1: Create a Hubspot Developer Account

Visit the Hubspot portal (https://developers.hubspot.com/get-started) and create a Developer Account.


MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved
### Step 2: Create a Hubspot Developer Test Account
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved

Visit (https://developers.hubspot.com/beta-docs/getting-started/account-types#developer-test-accounts)and create a hubspot developer test account
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

### Step 3: Create a Hubspot Public App
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved

In your developer account, navigate to the "Apps" section.

Click on "Create App" and provide the necessary details, including the app name and description.

ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

### Step 4: Initiate the OAuth Flow

Move to the auth tab in the created app and set the permissions there .
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

Under the OAuth tab you can find the following details ,
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

client_id: Your app's Client ID.

redirect_uri: The URL users will be redirected to after granting access.

scope: A space-separated list of scopes your app is requesting.
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

![Auth Tab example](docs/setup/resources/auth.png)
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved


### Step 5: Add the redirect URL
Add your redirect url under the redirect urls.


![alt text](docs/setup/resources/redirect_url.png)
MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved


### Step 6: Add the Required Scopes

Go to the relevant API documentation (https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions) and find out the required scopes.
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

![Requied Scope doc](docs/setup/resources/scope_doc.png)
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved


ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

Now come back to the Auth Page and add the required scopes under the Auth tab .
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved


MohamedSabthar marked this conversation as resolved.
Show resolved Hide resolved

![Required Scopes](docs/setup/resources/scopes.png)

Now save the app
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

![Save the app](docs/setup/resources/save.png)

### Step 7: Obtain the authorization code

Copy the App installation url and paste it in the web browser.

![Redirect URL ](docs/setup/resources/redirect.png)

## Quickstart

[//]: # (TODO: Add a quickstart guide to demonstrate a basic functionality of the module, including sample code snippets.)

It wll prompt you to install the App and then select your deveper test account.


ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

After selcting the developertest account, you will receive a authorization code displalyed in the browser.

![Obtain the authorization code](docs/setup/resources/authorization_code.png)

### Step 8: Obtain the access token


Place your authorization code, client_id and client_secret in the folowing comand and execute it in the terminal
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

'curl --request POST \
--url https://api.hubapi.com/oauth/v1/token \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'grant_type=authorization_code&code=<code>&redirect_uri=http://localhost:9090&client_id=<client_id>&client_secret=<client_secret>'
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

If the command executes successfully , you will receive the access token from the response.
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved


### Step 9: Obtaining the developer API key .

Follow the instructions at (https://developers.hubspot.com/docs/api/developer-tools-overview#developer-api-keys) to obtain the developer API key.


ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

## Quickstart

To begin using the `Hubspot Automation API` connector in your Ballerina application, you'll need to follow these steps:


### Step 1: Import the connector

First, import the `ballerinax/hubspot.automation.actions` package into your Ballerina project.

```ballerina
import ballerinax/hubspot.automation.actions;
```

### Step 2: Instantiate a new connector

Create a `actions:ConnectionConfig` object with your domain and developer API token, and initialize the connector.

```ballerina
actions:ConnectionConfig config = {
auth:{
hapikey:"<developer-api-key>" ,
private\-app\-legacy: ""
}
};
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved
actions:Client hubspotAutomation = check new (config);
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved
```

### Step 3: Invoke the connector operation

Utilize the connector's operations to manage extentions and functions.
#### Create an extenstion
ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

```ballerina

actions:FieldTypeDefinition typeDefinition = {
referencedObjectType: "OWNER",
externalOptions: false,
externalOptionsReferenceType: "",
name: "optionsInput",
'type: "enumeration",
fieldType: "select",
optionsUrl: "https://webhook.site/94d09471-6f4c-4a7f-bae2-c9a585dd41e0",
options: []
};

actions:InputFieldDefinition inputFieldDefinition = {
isRequired: true,
automationFieldType: "",
typeDefinition: typeDefinition,
supportedValueTypes: ["STATIC_VALUE"]
};



actions:PublicActionFunction publicActionFunction = {
functionSource: "exports.main = (event, callback) => {\r\n callback({\r\n outputFields: {\r\n myOutput: \"example output value\"\r\n }\r\n });\r\n}",
functionType: "POST_ACTION_EXECUTION"
};

actions:PublicActionDefinitionEgg testingPublicActionDefinitionEgg = {
inputFields: [inputFieldDefinition],
actionUrl: "https://webhook.site/94d09471-6f4c-4a7f-bae2-c9a585dd41e0",
published: false,
objectTypes: ["CONTACT"],
objectRequestOptions: { properties: ["email"] },
functions: [publicActionFunction],
labels: {
"en": {
"inputFieldLabels": {
"staticInput": "Static Input",
"objectInput": "Object Property Input",
"optionsInput": "External Options Input"
},
"actionName": "My Extension",
"actionDescription": "My Extension Description",
"appDisplayName": "My App Display Name",
"actionCardContent": "My Action Card Content"
}
}
};



ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

actions: PublicActionDefinition response = check hubspotAutomation->/automation/v4/actions/[appId].post(testingPublicActionDefinitionEgg);
```

#### List definitions

```ballerina

actions : CollectionResponsePublicActionDefinitionForwardPaging response = check hubspotAutomation->/automation/v4/actions/[appId];

ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved
```

## Examples

The `HubSpot Automation Action` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-hubspot.automation.actions/tree/main/examples/), covering the following use cases:
The `Hubspot Automation API` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](../examples/), covering the following use cases:

1. [Extension CRUD](../examples/) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](../examples/) - complete callbacks using the Hubspot API




ParameswaranSajeenthiran marked this conversation as resolved.
Show resolved Hide resolved

[//]: # (TODO: Add examples)

## Build from the source

Expand Down
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ name = "hubspot.automation.actions"
version = "1.0.0"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = []
# icon = "icon.png" # TODO: update icon.png
keywords = [] # TODO: Add keywords
# icon = "icon.png" # TODO: Add icon
repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.automation.actions"

[build-options]
observabilityIncluded = true

[platform.java21]
[platform.java17]
graalvmCompatible = true
Loading