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

Generated client using OpenAPI spec tool, Updated package.md and Added tests #2

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
416d456
Added openapi specifications
Nayanatharapmc Dec 17, 2024
24e29d2
Sanitized date-time to datetime
Nayanatharapmc Dec 17, 2024
5f0cb2f
Generated connector code using Ballerina OpenAPI tool
Nayanatharapmc Dec 17, 2024
ef94d97
Commented out java version
Nayanatharapmc Dec 18, 2024
26ecf05
Successfully built the repo
Nayanatharapmc Dec 20, 2024
211d320
Updated overview
Nayanatharapmc Dec 20, 2024
c7c60df
HubSpot URL added
Nayanatharapmc Dec 20, 2024
c8a40a2
Added the overview and setup guide
Nayanatharapmc Dec 20, 2024
1252c84
[Automated] Update the toml files
Nayanatharapmc Dec 22, 2024
de171ec
Passed the test case for getTickets()
Nayanatharapmc Dec 22, 2024
0574a6a
[Automated] Update the toml files
Nayanatharapmc Dec 23, 2024
e8f8206
[Automated] Update the toml files
Nayanatharapmc Dec 23, 2024
4dd69c7
Added test function to get ticket by Id
Nayanatharapmc Dec 23, 2024
8e68865
Updated test case to create a new ticket
Nayanatharapmc Dec 25, 2024
0b07e0d
[Automated] Update the toml files
Nayanatharapmc Dec 26, 2024
b082fc9
[Automated] Update the toml files
Nayanatharapmc Dec 26, 2024
710fc2c
Included test cases to check all the endponts
Nayanatharapmc Dec 26, 2024
34ab477
Updated package version
Nayanatharapmc Dec 26, 2024
24f4717
Updated readme
Nayanatharapmc Dec 27, 2024
907f88c
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
3a8c37a
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
d7e9c16
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
02e2bba
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
f070262
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
1ce56f0
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
abe9c5f
Updated Package.md
Nayanatharapmc Dec 27, 2024
7d47736
[Automated] Update the toml files
Nayanatharapmc Dec 27, 2024
8f16ea6
Updated tests
Nayanatharapmc Dec 28, 2024
7cbff24
[Automated] Update the toml files
Nayanatharapmc Jan 2, 2025
789388f
[Automated] Update the toml files
Nayanatharapmc Jan 2, 2025
8ce32fb
Updated tests
Nayanatharapmc Jan 2, 2025
978af67
Updated overview
Nayanatharapmc Jan 3, 2025
78cc3fe
Updated server URL and API paths in the OpenAPI spec
Nayanatharapmc Jan 3, 2025
05f782d
[Automated] Update the toml files
Nayanatharapmc Jan 3, 2025
089fc30
Regenerated client code
Nayanatharapmc Jan 3, 2025
faa6325
[Automated] Update the toml files
Nayanatharapmc Jan 5, 2025
ad2a778
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
8e11c80
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
318080e
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
2db7205
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
8c66075
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
034e03e
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
e475918
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
4ab5f96
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
c98bfcb
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
ec206ad
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
c9cfbdb
[Automated] Update the toml files
Nayanatharapmc Jan 6, 2025
6202eeb
[Automated] Update the toml files
Nayanatharapmc Jan 7, 2025
f95b301
[Automated] Update the toml files
Nayanatharapmc Jan 7, 2025
c740fb0
[Automated] Update the toml files
Nayanatharapmc Jan 7, 2025
0f7f121
[Automated] Update the toml files
Nayanatharapmc Jan 7, 2025
44d7d0e
Updated tests
Nayanatharapmc Jan 7, 2025
c8c8830
Updated Readme
Nayanatharapmc Jan 7, 2025
4a53e35
Regenerated client code including the WSO2 licensing header
Nayanatharapmc Jan 7, 2025
f94f416
Update README.md
Nayanatharapmc Jan 7, 2025
d2c587e
Update README.md
Nayanatharapmc Jan 7, 2025
cbdc5df
Added example weekly-ticket-reports
Nayanatharapmc Jan 9, 2025
404b55b
Added example 2 - Ticket management system
Nayanatharapmc Jan 9, 2025
11fc71b
Added readme.md for examples
Nayanatharapmc Jan 9, 2025
f67a284
Resolved commented issues
Nayanatharapmc Jan 9, 2025
6d408b6
Updated example readme files
Nayanatharapmc Jan 9, 2025
76b3a0a
Updated keywords
Nayanatharapmc Jan 9, 2025
e1c163a
Updated URL of examples
Nayanatharapmc Jan 9, 2025
fc7472e
Updated image paths
Nayanatharapmc Jan 9, 2025
bb1d5b0
Resolved commented issues
Nayanatharapmc Jan 9, 2025
b0d0d45
Resolved commented issues
Nayanatharapmc Jan 9, 2025
5d4e66e
Resolved commented issues
Nayanatharapmc Jan 9, 2025
c44c605
Formatted ballerina code
Nayanatharapmc Jan 9, 2025
4aa53bf
[Automated] Update the toml files
Nayanatharapmc Jan 10, 2025
3c2dc30
[Automated] Update the toml files
Nayanatharapmc Jan 10, 2025
3213f2e
Added hubspot icon
Nayanatharapmc Jan 10, 2025
7cfa799
Updated example package links in the documentation
Nayanatharapmc Jan 10, 2025
5fc6237
changed example path
Nayanatharapmc Jan 10, 2025
4a836a6
Added WSO2 license
Nayanatharapmc Jan 11, 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: 170 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,192 @@

[![Build](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/ci.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/ci.yml)
[![Trivy](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/trivy-scan.yml)
[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/build-with-bal-test-graalvm.yml)
[![GraalVM Check](https://gi'Authorization': 'Bearer YOUR_EMAIL_API_KEY',
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
'Content-Type': 'application/json',
},thub.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/actions/workflows/build-with-bal-test-graalvm.yml)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets.svg)](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/commits/master)
[![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/hubspot.crm.object.tickets.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%hubspot.crm.object.tickets)

## Overview

[//]: # (TODO: Add overview mentioning the purpose of the module, supported REST API versions, and other high-level details.)
HubSpot is an AI-powered customer relationship management (CRM) platform.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

The `ballerinax/hubspot.crm.object.tickets` offers APIs to connect and interact with the [module-ballerinax-hubspot.crm.object.tickets](https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets/) endpoints, specifically based on the [Tickets endpoint reference](https://developers.hubspot.com/beta-docs/guides/api/crm/objects/tickets).
Nayanatharapmc 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 CRM Object Tickets` connector, you must have access to the HubSpot API through a HubSpot developer account and an app under it. If you do not have a HubSpot developer account, you can sign up for one [here](https://developers.hubspot.com/get-started).

### Step 1: Create a HubSpot Developer Account

App Developer Accounts, allow you to create developer test accounts to test apps.

**_These accounts are only for development and testing purposes. Not to be used in production._**
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

1. Go to **Test Account section** from the left sidebar.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/test_acc_img1.png" alt="hubspot developer portal" width="70%"/>
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

2. Click **Create developer test account**.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/test_acc_img2.png" alt="Hubspot developer testacc" style="width: 70%;">

3. In the next dialogue box, give a name to your test account and enter create.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/test_acc_img3.png" alt="Hubspot developer testacc name" style="width: 70%;">

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

1. In your developer account, navigate to the **"Apps"** section. Click on **"Create App"**
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
<img src="docs/setup/resources/app_img1.png" alt="Hubspot app creation 1 testacc" style="width: 70%;">

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

### Step 3: Configure the Authentication Flow.

1. Move to the Auth Tab.

<img src="docs/setup/resources/auth.png" alt="Hubspot app auth tab" style="width: 70%;">

2. In the **Scopes** section, add the following scopes for your app using the **"Add new scope"** button.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

`tickets`
`oath`
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/scope_select.png" alt="Scope selection" style="width: 70%;">

3. Add your **Redirect URI** in the relevant section. You can use localhost addresses for local development purposes. Then Click **Create App**.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/redirect_url.png" alt="Redirect URI" style="width: 70%;">

### Step 4: 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.
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

<img src="docs/setup/resources/credentials.png" alt="Credentials" style="width: 70%;">

### Step 5: 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 the above obtained values.

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

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

Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
```
Received code: na1-129d-860c-xxxx-xxxx-xxxxxxxxxxxx
```
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

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 and refresh 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 Object Tickets` connector in your Ballerina application, update the `.bal` file as follows:

### Step 1: Import the module

Import the `hubspot.crm.objects.tickets` module and `oauth2` module.

```ballerina
import ballerinax/hubspot.crm.object.tickets as hstickets;
import ballerina/oauth2;
```

### Step 2: Instantiate a new connector

1. Create a `Config.toml` file and, configure the obtained credentials obtained in the above steps as follows:
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved

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

2. Instantiate a `OAuth2RefreshTokenGrantConfig` with the obtained credentials and initialize the connector with it.

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

OAuth2RefreshTokenGrantConfig auth = {
clientId,
clientSecret,
refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
};

ConnectionConfig config = {auth};
final Client HubSpotClient = check new Client(config, "https://api.hubapi.com");
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
```

### Step 3: Invoke the connector operation

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

#### Create a New Ticket

```ballerina
public function main() returns error? {
SimplePublicObjectInputForCreate payload = {
properties: {
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_priority": "HIGH",
"subject": "New troubleshoot report"
}
};
SimplePublicObject response = check HubSpotClient->/crm/v3/objects/tickets.post(payload);
io:println(response5);
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
return;
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
}
```

## Examples

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

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

## Build from the source

Expand Down
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
distribution = "2201.10.0"
org = "ballerinax"
name = "hubspot.crm.object.tickets"
name = "hubspot.crm.obj.tickets"
version = "1.0.0"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = []
# icon = "icon.png" # TODO: update icon.png
keywords = [] # TODO: Add keywords
Nayanatharapmc marked this conversation as resolved.
Show resolved Hide resolved
# icon = "icon.png" # TODO: Add icon
repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.crm.object.tickets"

[build-options]
observabilityIncluded = true

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