Skip to content

Commit

Permalink
Generated client using OpenAPI spec tool, Updated package.md, module.…
Browse files Browse the repository at this point in the history
…md and Added tests
  • Loading branch information
roshanemoraes committed Jan 3, 2025
1 parent e781136 commit afc80a5
Show file tree
Hide file tree
Showing 26 changed files with 3,556 additions and 41 deletions.
153 changes: 136 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,149 @@

## Overview

[//]: # (TODO: Add overview mentioning the purpose of the module, supported REST API versions, and other high-level details.)
[//]: # "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 customer platform with all the software, integrations, and resources users need to connect thier marketing, sales, and customer service.

The `ballerinax/hubspot.crm.commerce.orders` package offers APIs to connect and interact with [HubSpot API for CRM Commerce Orders](https://developers.hubspot.com/docs/reference/api/crm/commerce/orders) endpoints, specifically based on [HubSpot CRM Commerce Orders API v3 OpenAPI spec](https://github.com/HubSpot/HubSpot-public-api-spec-collection/blob/main/PublicApiSpecs/CRM/Orders/Rollouts/424/v3/orders.json).

## Setup guide

[//]: # (TODO: Add detailed steps to obtain credentials and configure the module.)
[//]: # "TODO: Add detailed steps to obtain credentials and configure the module."

To use the HubSpot CRM Commerce Orders 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.

**_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.

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/test_acc_1.png alt="Hubspot developer portal" style="width: 70%;">

2. Click Create developer test account.

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/test_acc_2.png alt="Hubspot developer testacc" style="width: 70%;">

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

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/test_acc_3.png alt="Hubspot developer testacc3" style="width: 70%;">

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

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

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/create_app_1.png alt="Hubspot app creation 1 testacc3" style="width: 70%;">

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

### Step 4: Configure the Authentication Flow.

1. Move to the Auth Tab.

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/create_app_2.png alt="Hubspot app creation 2 testacc3" style="width: 70%;">

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

`crm.objects.orders.read`

`crm.objects.orders.write`

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/scope_set.png alt="Hubspot app creation 1 testacc3" style="width: 70%;">

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

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/create_app_final.png alt="Hubspot app creation 1 testacc3" style="width: 70%;">

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

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/get_credentials.png alt="Hubspot app creation 1 testacc3" style="width: 70%;">

### 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 listner 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 listner to the port._**

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

<img src=https://raw.githubusercontent.com/roshanemoraes/module-ballerinax-hubspot.crm.commerce.orders/main/docs/setup/resources/install_app.png alt="Hubspot app creation 1 testacc3" style="width: 70%;">

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

```
Received code: na1-129d-860c-xxxx-xxxx-xxxxxxxxxxxx
```

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.)
[//]: # "TODO: Add a quickstart guide to demonstrate a basic functionality of the module, including sample code snippets."

## Examples

The `HubSpot CRM Commerce Orders` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-hubspot.crm.commerce.orders/tree/main/examples/), covering the following use cases:

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

## Build from the source

### Setting up the prerequisites

1. Download and install Java SE Development Kit (JDK) version 21. You can download it from either of the following sources:

* [Oracle JDK](https://www.oracle.com/java/technologies/downloads/)
* [OpenJDK](https://adoptium.net/)
- [Oracle JDK](https://www.oracle.com/java/technologies/downloads/)
- [OpenJDK](https://adoptium.net/)

> **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed.

Expand All @@ -43,10 +162,10 @@ The `HubSpot CRM Commerce Orders` connector provides practical examples illustra

4. Export Github Personal access token with read package permissions as follows,

```bash
export packageUser=<Username>
export packagePAT=<Personal access token>
```
```bash
export packageUser=<Username>
export packagePAT=<Personal access token>
```

### Build options

Expand Down Expand Up @@ -90,9 +209,9 @@ Execute the commands below to build from the source.

7. Publish the generated artifacts to the local Ballerina Central repository:

```bash
./gradlew clean build -PpublishToLocalCentral=true
```
```bash
./gradlew clean build -PpublishToLocalCentral=true
```

8. Publish the generated artifacts to the Ballerina Central repository:

Expand All @@ -112,7 +231,7 @@ All the contributors are encouraged to read the [Ballerina Code of Conduct](http

## Useful links

* For more information go to the [`hubspot.crm.commerce.orders` package](https://central.ballerina.io/ballerinax/hubspot.crm.commerce.orders/latest).
* For example demonstrations of the usage, go to [Ballerina By Examples](https://ballerina.io/learn/by-example/).
* Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
- For more information go to the [`hubspot.crm.commerce.orders` package](https://central.ballerina.io/ballerinax/hubspot.crm.commerce.orders/latest).
- For example demonstrations of the usage, go to [Ballerina By Examples](https://ballerina.io/learn/by-example/).
- Chat live with us via our [Discord server](https://discord.gg/ballerinalang).
- Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.
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.commerce.orders"
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.crm.commerce.orders"

[build-options]
observabilityIncluded = true

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

0 comments on commit afc80a5

Please sign in to comment.