Skip to content

Commit

Permalink
review changes implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
ParameswaranSajeenthiran committed Dec 20, 2024
1 parent 2a1dab2 commit acbce5b
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 206 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
[HubSpot ](https://www.hubspot.com/) is an AI-powered customer platform with all the software, integrations, and resources you need to connect your marketing, sales, and customer service. HubSpot's connected platform enables you to grow your business faster by focusing on what matters most: your customers.


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


The `hubspot.automation.actions` package offers APIs to connect and interact with [Hubpsot Automation action API](https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions) endpoints.

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.

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the Hubpsot Automation action API connector in Ballerina, you must have a HubSpot developer account.

### Step 1: Create a Hubspot Developer Account
Expand Down Expand Up @@ -209,14 +208,13 @@ hubspot.automation.actions : CollectionResponsePublicActionDefinitionForwardPagi

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

1. [Extension CRUD](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/multi-channel-support-integration) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/customer-satisfaction-survey-analysis) - complete callbacks using the Hubspot API
1. [Extension CRUD](examples) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](examples) - complete callbacks using the Hubspot API





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

## Build from the source

Expand Down
203 changes: 197 additions & 6 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,208 @@
## 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 platform with all the software, integrations, and resources you need to connect your marketing, sales, and customer service. HubSpot's connected platform enables you to grow your business faster by focusing on what matters most: your customers.





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.

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the Hubpsot Automation action API connector in Ballerina, you must have a HubSpot developer account.

### Step 1: Create a Hubspot Developer Account

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

### Step 2: Create a Hubspot Developer Account

Create a Developer Test Account at (https://developers.hubspot.com/beta-docs/getting-started/account-types#developer-test-accounts)

### Step 3: Create a Hubspot Develop Test Account

Visit (https://developers.hubspot.com/beta-docs/getting-started/account-types#developer-test-accounts)and create a hubspot developer test account

### Step 4: Create a Hubspot Public App

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

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


### Step 5: Initiate the OAuth Flow

Move to the auth tab in the created app and set the permissions there .

Under the OAuth tab you can find the following details ,


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.

![Auth Tab example](/home/sajeenthiran/projects/module-ballerinax-hubspot.automation.actions/docs/setup/resources/auth.png)


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

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


### Step 7: 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.


![Requied Scope doc](docs/setup/resources/scope_doc.png)



Now come back to the Auth Page and add the required scopes under the Auth tab .



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

Now save the app

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

### Step 8: Obtain the authorization code

Copy the App installation url and paste it in the web browser. It wll prompt you to install the App and then select your deveper test account.

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

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

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


Place your auhtorization code, client_id and client_screct in the folowing comand and execute it in the terminal

'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>'

If the command executes successfully , you will receive the access token from the response.


### Step 10 : 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.



## 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 `hubspot.automation.actions:ConnectionConfig` object with your domain and developer API token, and initialize the connector.

```ballerina
hubspot.automation.actions:ConnectionConfig automationClient = {
auth:{
hapikey:"<developer-api-key>" ,
private\-app\-legacy: ""
}
};
hubspot.automation.actions:Client automationClient = check new (automationClient);
```

### Step 3: Invoke the connector operation

Utilize the connector's operations to manage extentions and functions.
#### Create an extenstion

```ballerina
hubspot.automation.actions:FieldTypeDefinition typeDefinition = {
referencedObjectType: "OWNER",
externalOptions: false,
externalOptionsReferenceType: "",
name: "optionsInput",
'type: "enumeration",
fieldType: "select",
optionsUrl: "https://webhook.site/94d09471-6f4c-4a7f-bae2-c9a585dd41e0",
options: []
};
hubspot.automation.actions:InputFieldDefinition inputFieldDefinition = {
isRequired: true,
automationFieldType: "",
typeDefinition: typeDefinition,
supportedValueTypes: ["STATIC_VALUE"]
};
hubspot.automation.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"
};
hubspot.automation.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"
}
}
};
hubspot.automation.actions: PublicActionDefinition response = check automationClient->/automation/v4/actions/[appId].post(testingPublicActionDefinitionEgg);
```

#### List definitions

```ballerina
hubspot.automation.actions : CollectionResponsePublicActionDefinitionForwardPaging response = check automationClient->/automation/v4/actions/[appId];
```

## 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](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/), covering the following use cases:

1. [Extension CRUD](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/multi-channel-support-integration) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/customer-satisfaction-survey-analysis) - complete callbacks using the Hubspot API




[//]: # (TODO: Add examples)
11 changes: 5 additions & 6 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
[HubSpot ](https://www.hubspot.com/) is an AI-powered customer platform with all the software, integrations, and resources you need to connect your marketing, sales, and customer service. HubSpot's connected platform enables you to grow your business faster by focusing on what matters most: your customers.


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


The `hubspot.automation.actions` package offers APIs to connect and interact with [Hubpsot Automation action API](https://developers.hubspot.com/docs/reference/api/automation/custom-workflow-actions) endpoints.

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.

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the Hubpsot Automation action API connector in Ballerina, you must have a HubSpot developer account.

### Step 1: Create a Hubspot Developer Account
Expand Down Expand Up @@ -199,10 +198,10 @@ hubspot.automation.actions : CollectionResponsePublicActionDefinitionForwardPagi

## Examples

The `Hubspot Automation API` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-zendesk/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](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/multi-channel-support-integration) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](https://github.com/ballerina-platform/module-ballerinax-zendesk/tree/main/examples/customer-satisfaction-survey-analysis) - complete callbacks using the Hubspot API
1. [Extension CRUD](examples) - Perform CRUD operations on Extensions
2. [Call complete callback APIs](examples) - complete callbacks using the Hubspot API



Expand Down
5 changes: 3 additions & 2 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ConnectionConfig oauthConfig = {
// API Key Config
ConnectionConfig apikeyConfig = {auth:{

hapikey:"42c4fd68-72d9-49e7-8254-520f9acce400" ,
hapikey: apiKey,
private\-app\-legacy: ""
}};

Expand Down Expand Up @@ -136,8 +136,9 @@ function testGetDefinitionById() returns error? {
function testGetAllFunctions() returns error? {
io:println("requesting get all functions");
CollectionResponsePublicActionFunctionIdentifierNoPaging response = check automationClient->/automation/v4/actions/[appId]/[createdExtensionId]/functions;

//validate the response
// test:assertTrue(response?.results.length() > 0, "No functions found for the extension");
test:assertTrue(response?.results.length() > 0, "No functions found for the extension");
io:println("All functions retrieved successfully");


Expand Down
45 changes: 0 additions & 45 deletions examples/README.md

This file was deleted.

Loading

0 comments on commit acbce5b

Please sign in to comment.