Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe4ff28
Generate ballerina source code
CharanaManawathilake Dec 17, 2024
98aac45
[Automated] Update the toml files
CharanaManawathilake Dec 19, 2024
8e6699c
[Automated] Update the toml files
CharanaManawathilake Dec 19, 2024
419c377
Successful gradle build
CharanaManawathilake Dec 19, 2024
4c8a2e0
Update Package.md
CharanaManawathilake Dec 20, 2024
4576961
Functional tests
CharanaManawathilake Jan 3, 2025
44883c3
Unrefined completed tests
CharanaManawathilake Jan 6, 2025
f02e3b5
Refined completed tests
CharanaManawathilake Jan 6, 2025
613c6e4
Remove unwanted files
CharanaManawathilake Jan 6, 2025
ee3ae91
[Automated] Update the toml files
CharanaManawathilake Jan 6, 2025
854fa9a
Update sanitations documentation
CharanaManawathilake Jan 8, 2025
f652bf1
Update README.md
CharanaManawathilake Jan 8, 2025
43b9032
Resolve RP issues
CharanaManawathilake Jan 8, 2025
138904b
Replace package.md images
CharanaManawathilake Jan 8, 2025
25e889d
Update documentation
CharanaManawathilake Jan 9, 2025
a5767c8
Address PR comments
CharanaManawathilake Jan 9, 2025
b639c8c
[Automated] Update the toml files
CharanaManawathilake Jan 9, 2025
a9bcff5
[Automated] Update the toml files
CharanaManawathilake Jan 9, 2025
1c01897
[Automated] Update the toml files
CharanaManawathilake Jan 9, 2025
bcfacba
[Automated] Update the toml files
CharanaManawathilake Jan 9, 2025
67d4b4c
Change Org in toml files
CharanaManawathilake Jan 9, 2025
6dab76c
Add image and minor adjustments in md files
CharanaManawathilake Jan 9, 2025
18cd5ac
[Automated] Update the toml files
CharanaManawathilake Jan 9, 2025
eacd195
Remove seperate listener
CharanaManawathilake Jan 9, 2025
015d645
Format the .bal files
CharanaManawathilake Jan 9, 2025
fb76a2f
Address the PR comments
CharanaManawathilake Jan 10, 2025
95bbb1f
Create license issue
CharanaManawathilake Jan 10, 2025
ebeecf7
Correct the license issue
CharanaManawathilake Jan 10, 2025
1f5ef91
[Automated] Update the toml files
CharanaManawathilake Jan 10, 2025
efd1e5c
Move icon.png file
CharanaManawathilake 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
177 changes: 163 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,177 @@
# Ballerina HubSpot CRM Import connector

[![Build](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/ci.yml)
[![Trivy](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/trivy-scan.yml)
[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/actions/workflows/build-with-bal-test-graalvm.yml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-hubspot.crm.import.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/commits/master)
[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/hubspot.crm.import.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%hubspot.crm.import)

## Overview

[//]: # (TODO: Add overview mentioning the purpose of the module, supported REST API versions, and other high-level details.)
[HubSpot](https://www.hubspot.com/our-story) is an AI-powered customer relationship management (CRM) platform.

The `ballerinax/hubspot.crm.imports` offers APIs to connect and interact with the [HubSpot CRM Imports API](https://developers.hubspot.com/docs/api/crm/imports) endpoints, specifically based on the [HubSpot CRM Imports API v3 OpenAPI spec](https://github.com/HubSpot/HubSpot-public-api-spec-collection/blob/main/PublicApiSpecs/CRM/Imports/Rollouts/144903/v3/imports.json)

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
To use the HubSpot CRM imports 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://app.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](https://developers.hubspot.com/beta-docs/getting-started/account-types#developer-test-accounts) under your account

Within app developer accounts, you can create developer test accounts 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 Account section from the left sidebar.

![Hubspot developer portal](./docs/setup/resources/test_acc_1.png)

2. Click Create developer test account.

![Hubspot developer test account](./docs/setup/resources/test_acc_2.png)

3. In the dialogue box, give a name to your test account and click create.

![Create Hubspot developer test account](./docs/setup/resources/test_acc_3.png)

### Step 3: Create a HubSpot App under your account.

1. In your developer account, navigate to the "Apps" section. Click on "Create App"

![Hubspot apps](./docs/setup/resources/create_app_1.png)

2. Provide the necessary details, including the app name and description.

### Step 4: Configure the Authentication Flow.

1. Move to the Auth Tab.

![Hubspot app auth tab](./docs/setup/resources/create_app_2.png)

2. In the Scopes section, add the following scopes for your app using the "Add new scope" button.

`crm.objects.import`

![Add new scope](./docs/setup/resources/scope_set.png)

4. Add your Redirect URI in the relevant section. You can also use localhost addresses for local development purposes. Click Create App.

![Create app](./docs/setup/resources/create_app_final.png)

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

- Navigate to the Auth section of your app. Make sure to save the provided Client ID and Client Secret.

![Auth settings](./docs/setup/resources/get_credentials.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.

**_NOTE: If you are using a localhost redirect url, make sure to have a listener running at the relevant port before executing the next step. You can use [this gist](https://gist.github.com/lnash94/0af47bfcb7cc1e3d59e06364b3c86b59) and run it using `bal run`. Alternatively, you can use any other method to bind a listener to the port._**

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

![Choose account](./docs/setup/resources/install_app.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>`.

- 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 CRM Imports` connector in your Ballerina application, update the `.bal` file as follows:

## Examples
### Step 1: Import the module

Import the `hubspot.crm.import` module and `oauth2` module.

```ballerina
import ballerinax/hubspot.crm.'import as crmImport;
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 `crmImport:ConnectionConfig` with the obtained credentials and initialize the connector with it.

The `HubSpot CRM Import` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-hubspot.crm.import/tree/main/examples/), covering the following use cases:
```ballerina
configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;

final crmImport:ConnectionConfig config = {
auth : {
clientId,
clientSecret,
refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
}
};

final crmImport:Client baseClient = check new crmImport:Client(config);
```

### Step 3: Invoke the connector operation

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

#### Get a paged list of active imports

```ballerina
public function main() returns error? {
crmImport:CollectionResponsePublicImportResponse response = check baseClient->/.get({});
}
```

## Examples

[//]: # (TODO: Add examples)
The `HubSpot.crm.imports` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import/tree/main/examples), covering the following use cases:

## 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.crm.import"
version = "1.0.0"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = []
# icon = "icon.png" # TODO: update icon.png
keywords = ["hubspot","crm","imports"]
# icon = "https://raw.githubusercontent.com/ballerina-platform/module-ballerinax-hubspot.crm.import/main/docs/setup/resources/icon.png"
repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.import"

[build-options]
observabilityIncluded = true

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