Skip to content
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
1a94925
Generated bal files
SamudraUduwaka Dec 18, 2024
de93285
API file upload
SamudraUduwaka Dec 18, 2024
3759a6b
Merge pull request #1 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Dec 18, 2024
80642f2
Add Dependencies.toml file
SamudraUduwaka Dec 19, 2024
704478f
Merge pull request #2 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Dec 19, 2024
fed3dd6
Update documentation for private\-app
SamudraUduwaka Dec 19, 2024
b125141
Merge pull request #3 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Dec 19, 2024
807b586
[Automated] Update the toml files
SamudraUduwaka Dec 19, 2024
9935e65
Update README.md
SamudraUduwaka Dec 20, 2024
1189825
Update README.md
SamudraUduwaka Dec 20, 2024
6920c4b
Adding tests folder
SamudraUduwaka Dec 20, 2024
c5ab7bd
[Automated] Update the toml files
SamudraUduwaka Dec 20, 2024
d44b5e3
Adding Overview and Setup Guide
SamudraUduwaka Jan 1, 2025
696ffeb
Adding Quickstart Guide
SamudraUduwaka Jan 1, 2025
f9c8a69
Update Quickstart Guide
SamudraUduwaka Jan 1, 2025
3821182
Create Resources Folder
SamudraUduwaka Jan 1, 2025
fb66037
Add Resources
SamudraUduwaka Jan 1, 2025
00a2bf0
Update Setup Guide
SamudraUduwaka Jan 2, 2025
f65e5a8
Update README.md
SamudraUduwaka Jan 2, 2025
6476040
Update Package.md
SamudraUduwaka Jan 2, 2025
0ed4781
[Automated] Update the toml files
SamudraUduwaka Jan 6, 2025
1b87f37
Re-generate Client with Sanitation for baseURL
SamudraUduwaka Jan 6, 2025
69a309c
Re-generate Client with Sanitation for PublicCampaignAsset
SamudraUduwaka Jan 6, 2025
a3245b4
Update Documentation for private\-app
SamudraUduwaka Jan 6, 2025
94e2b5e
Update sanitations.md
SamudraUduwaka Jan 6, 2025
02d8ae2
[Automated] Update the toml files
SamudraUduwaka Jan 6, 2025
14aba20
[Automated] Update the toml files
SamudraUduwaka Jan 6, 2025
5ff8221
[Automated] Update the toml files
SamudraUduwaka Jan 7, 2025
c5c31b1
Add Test Cases for End-points
SamudraUduwaka Jan 7, 2025
cf7bced
Updated sanitations.md
SamudraUduwaka Jan 7, 2025
f0396b6
[Automated] Update the toml files
SamudraUduwaka Jan 7, 2025
0d70592
Added WSO2 licensing header
SamudraUduwaka Jan 7, 2025
615f088
Merge pull request #4 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Jan 7, 2025
4dfcc68
Update README.md
SamudraUduwaka Jan 7, 2025
2bfbe60
Added Keywords
SamudraUduwaka Jan 7, 2025
fc569ad
Update Package.md
SamudraUduwaka Jan 7, 2025
2db503c
Delete docs/Resources/README.md
SamudraUduwaka Jan 7, 2025
89f1eae
Update sanitations.md
SamudraUduwaka Jan 7, 2025
074a36e
Update README.md
SamudraUduwaka Jan 8, 2025
c59cf64
Update Package.md
SamudraUduwaka Jan 8, 2025
4fe6060
Code refinements in test.bal
SamudraUduwaka Jan 8, 2025
e302568
Code refinements in test.bal
SamudraUduwaka Jan 8, 2025
a04defc
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
635d660
Update README.md
SamudraUduwaka Jan 8, 2025
27e52d5
Update README.md
SamudraUduwaka Jan 8, 2025
5bea6ce
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
a20f68f
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
b9956e9
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
dafe9fd
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
dd27a21
updated test.bal
SamudraUduwaka Jan 8, 2025
46d5f8a
Merge pull request #6 from SamudraUduwaka/main
SamudraUduwaka Jan 8, 2025
4f721bb
Add mock_service and mock_test files
SamudraUduwaka Jan 8, 2025
7da338e
Update README.md
SamudraUduwaka Jan 8, 2025
283ab2b
Update Package.md
SamudraUduwaka Jan 8, 2025
283ef68
Delete README in tests folder
SamudraUduwaka Jan 8, 2025
be7c1bf
Update test.bal
SamudraUduwaka Jan 8, 2025
c24deda
Update test.bal
SamudraUduwaka Jan 8, 2025
2e18f80
Merge pull request #7 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Jan 8, 2025
860fe9e
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
7328ed2
[Automated] Update the toml files
SamudraUduwaka Jan 8, 2025
fe994ff
Updated sanitations.md
SamudraUduwaka Jan 8, 2025
24246f2
Update the links in documentation images
ThisaruGuruge Jan 9, 2025
9efe90a
Added Example - Batch_of_Campaigns
SamudraUduwaka Jan 10, 2025
a7024a0
Add Example - Campaign_LifeCycle_with_Assets
SamudraUduwaka Jan 10, 2025
d88829e
Merge pull request #8 from SamudraUduwaka/feature/campaigns
SamudraUduwaka Jan 10, 2025
16ddf5b
Apply suggestions from code review
ThisaruGuruge Jan 10, 2025
f2f7b84
Update README.md in Examples
SamudraUduwaka Jan 10, 2025
8c2b0c8
Update Package.md
SamudraUduwaka Jan 10, 2025
c7971fa
Update Module.md
SamudraUduwaka Jan 10, 2025
4dfe462
Update README.md
SamudraUduwaka Jan 10, 2025
5d53496
Merge branch 'main' into main
ThisaruGuruge Jan 10, 2025
97bf1ed
Update Package.md and Module.md
SamudraUduwaka Jan 10, 2025
eb11c91
Merge pull request #9 from ThisaruGuruge/main
SamudraUduwaka Jan 10, 2025
ba4e82f
Merge branch 'main' of https://github.com/SamudraUduwaka/module-balle…
SamudraUduwaka Jan 10, 2025
2edce2c
Adding mock_service and mock_tests
SamudraUduwaka Jan 10, 2025
87a1047
Merge pull request #10 from ballerina-platform/main
SamudraUduwaka Jan 10, 2025
6e9497b
Update README.md
SamudraUduwaka Jan 11, 2025
34d64e4
Update README.md
SamudraUduwaka Jan 16, 2025
85128bb
Merge branch 'main' of https://github.com/SamudraUduwaka/module-balle…
SamudraUduwaka Jan 16, 2025
9f8069c
Update README.md
SamudraUduwaka Jan 16, 2025
0b332fe
Update Module.md and Package.md
SamudraUduwaka Jan 16, 2025
95004d6
Update mock_tests.bal
SamudraUduwaka Jan 16, 2025
03d86ad
Update README.md
SamudraUduwaka Jan 16, 2025
fe1cc10
Update Module.md
SamudraUduwaka Jan 16, 2025
e44a7f8
Update Package.md
SamudraUduwaka Jan 16, 2025
46073b1
Update README.md
SamudraUduwaka Jan 16, 2025
9efa884
remove empty line
SamudraUduwaka Jan 16, 2025
0321be7
Updated folder structure
SamudraUduwaka Jan 16, 2025
cf571f9
Added resources folder
SamudraUduwaka Jan 16, 2025
a9e2fd0
Update Repository Structure
SamudraUduwaka Jan 16, 2025
9365a3c
Added Examples
SamudraUduwaka Jan 16, 2025
6c138ff
Update mock tests
SamudraUduwaka Jan 16, 2025
8b7e9f1
Update tests file
SamudraUduwaka Jan 16, 2025
25e34dc
Update Module.md
SamudraUduwaka Jan 17, 2025
45b457e
Update Package.md
SamudraUduwaka Jan 17, 2025
f2f98a7
Update README.md
SamudraUduwaka Jan 17, 2025
2ac07a6
Update Module.md
SamudraUduwaka Jan 17, 2025
f450a53
Update Package.md
SamudraUduwaka Jan 17, 2025
71b3f03
Update README.md
SamudraUduwaka Jan 17, 2025
b43b529
Update Package.md
SamudraUduwaka Jan 17, 2025
c5f47e8
Update Module.md
SamudraUduwaka Jan 17, 2025
172563e
Update listener port
SamudraUduwaka Jan 17, 2025
541f4ac
Update mock tests
SamudraUduwaka Jan 17, 2025
a0eae84
Apply suggestions from code review
ThisaruGuruge Jan 17, 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
175 changes: 169 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ballerina HubSpot Marketing Campaigns connector
# Ballerina HubSpot Marketing Campaigns Connector

[![Build](https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns/actions/workflows/ci.yml)
[![Trivy](https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns/actions/workflows/trivy-scan.yml)
Expand All @@ -8,21 +8,184 @@

## 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/module-ballerinax-hubspot.marketing.campaigns` connector offers APIs to connect and interact with the [Hubspot Marketing Campaigns API](https://developers.hubspot.com/docs/guides/api/marketing/campaigns) endpoints, specifically based on the [HubSpot REST API](https://developers.hubspot.com/docs/reference/api/overview)

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the HubSpot Marketing Campaigns connector, you must have access to the HubSpot API through a HubSpot developer account and a HubSpot App under it. Therefore you need to register for a developer account at HubSpot if you don't have one already.

### Step 1: Create/Login to a HubSpot Developer Account

If you have an account already, go to the [HubSpot developer portal](https://developers.hubspot.com/)

If you don't have a HubSpot Developer Account you can sign up to a free account [here](https://developers.hubspot.com/get-started)

### Step 2 (Optional): Create a Developer Test Account
Within app developer accounts, you can create a [developer test account](https://developers.hubspot.com/docs/getting-started/account-types#developer-test-accounts) under your account to test apps and integrations without affecting any real HubSpot data.

> **Note**: These accounts are only for development and testing purposes. In production you should not use Developer Test Accounts.

1. Go to Test accounts section from the left sidebar.

![Test Account](docs/resources/testAccount.png)

2. Click on the Create developer test account button on the top right corner.

![Development Test Account](docs/resources/developmentTestAccount.png)

3. In the pop-up window, provide a name for the test account and click on the Create button.

![Create Account](docs/resources/createAccount.png)

4. You will see the newly created test account in the list of test accounts.

![Test Account Portal](docs/resources/testAccountPortal.png)

### Step 3: Create a HubSpot App

1. Navigate to the Apps section from the left sidebar and click on the Create app button on the top right corner.

![App Section](docs/resources/appSection.png)

2. Provide a public app name and description for your app.

![Naming the App](docs/resources/namingApp.png)

### Step 4: Setup Authentication

1. Move to the Auth tab.

![Auth Section](docs/resources/auth.png)

2. In the Scopes section, add the following scopes for your app using the Add new scopes button.
- `marketing.campaigns.read`
- `marketing.campaigns.revenue.read`
- `marketing.campaigns.write`

![Marketing Scopes](docs/resources/marketingScopes.png)

3. In the Redirect URL section, add the redirect URL for your app. This is the URL where the user will be redirected after the authentication process. You can use `localhost` for testing purposes. Then click the "Create App" button.

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

### Step 5: Get the Client ID and Client Secret

Navigate to the Auth tab and you will see the `Client ID`, and `Client Secret` for your app. Make sure to save these values.

![Client ID and Client Secret](docs/resources/clientId_secretId.png)

### Step 6: Setup Authentication Flow

Before proceeding with the Quickstart, ensure you have obtained the Access Token using the following steps:

1. Create an authorization URL using the following format:

```
https://app.hubspot.com/oauth/authorize?client_id=<YOUR_CLIENT_ID>&scope=<YOUR_SCOPES>&redirect_uri=<YOUR_REDIRECT_URI>
```
Replace the `<YOUR_CLIENT_ID>`, `<YOUR_REDIRECT_URI>`, and `<YOUR_SCOPES>` with your specific value.

2. Paste it in the browser and select your developer test account to intall the app when prompted.

![Account Select](docs/resources/accountSelect.png)

3. A code will be displayed in the browser. Copy the code.

4. Run the following curl command. Replace the `<YOUR_CLIENT_ID>`, `<YOUR_REDIRECT_URI>`, and `<YOUR_CLIENT_SECRET>` with your specific value. Use the code you received in the above step 3 as the CODE below

- Linux/macOS
```bash
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=<YOUR_REDIRECT_URI>&client_id=<YOUR_CLIENT_ID>&client_secret=<YOUR_CLIENT_SECRET>'
```

- Windows
```bash
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=<YOUR_REDIRECT_URI>&client_id=<YOUR_CLIENT_ID>&client_secret=<YOUR_CLIENT_SECRET>'
```

This command will return the access token necessary for API calls.

```json
{
"token_type": "bearer",
"refresh_token": "<Refresh Token>",
"access_token": "<Access Token>",
"expires_in": 1800
}
```

5. Store the access token securely for use in your application.


## Quickstart

[//]: # (TODO: Add a quickstart guide to demonstrate a basic functionality of the module, including sample code snippets.)
To use the HubSpot Marketing Campaigns connector in your Ballerina application, update the `.bal` file as follows:

### Step 1: Import the module

Import the `ballerinax/hubspot.marketing.campaigns` module and `ballerina/oauth2` module.

```ballerina
import ballerinax/hubspot.marketing.campaigns as hsmcampaigns;
import ballerina/oauth2;
```

### Step 2: Instantiate a new connector

1. Create a `Config.toml` file and, configure the obtained credentials in the above steps as follows:

```toml
clientId = <Client Id>
clientSecret = <Client Secret>
refreshToken = <Refresh Token>
```

2. Instantiate a `hsmcampaigns:ConnectionConfig` with the obtained credentials and initialize the connector with it.

```ballerina
configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;

final hsmcampaigns:ConnectionConfig hsmcampaignsConfig = {
auth : {
clientId,
clientSecret,
refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
}
};

final hsmcampaigns:Client hsmcampaignsClient = check new (hsmcampaignsConfig);
```

### Step 3: Invoke the connector operation

Now, utilize the available connector operations. A sample usecase is shown below.

Retrieve a Marketing Campaign

```ballerina
public function main() returns error? {
hsmcampaigns:CollectionResponseWithTotalPublicCampaignForwardPaging campaigns = check hsmcampaignsClient->/marketing/v3/campaigns.get();
}
```


## Examples

The `HubSpot Marketing Campaigns ` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-hubspot.marketing.campaigns/tree/main/examples/), covering the following use cases:
The `HubSpot Marketing Campaigns ` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns/tree/main/examples), covering the following use cases:

[//]: # (TODO: Add examples)
1. [Batch of Campaigns](examples/batch_of_campaigns) - Fully manage a batch of campaigns
2. [Campaign Lifecycle with Assets](examples/campaign_lifecycle_with_assets) - Full life cycle of a campaign associated with assets such as forms

## 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.marketing.campaigns"
version = "1.0.0"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = []
# icon = "icon.png" # TODO: update icon.png
keywords = ["hubspot", "crm", "marketing", "campaigns"]

repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.campaigns"

[build-options]
observabilityIncluded = true

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