-
Notifications
You must be signed in to change notification settings - Fork 2
Generate client using OpenAPI spec, start updating Quick Start and Setup Guide #2
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
40b6304
Add the generated client and related files
ShavinAnjithaAlpha 13a8bf1
Changing java version to 17
ShavinAnjithaAlpha d665c2d
Add openapi spec file
ShavinAnjithaAlpha a6d0d7a
Start editing overview and setup guide
ShavinAnjithaAlpha ccaf5c9
Add license banners to source files
ShavinAnjithaAlpha 63d29b6
Add dependencies file
ShavinAnjithaAlpha 641089d
[Automated] Update the toml files
ShavinAnjithaAlpha ebeafa5
[Automated] Update the toml files
ShavinAnjithaAlpha 3a8f84a
Update .gitignore file
ShavinAnjithaAlpha d742739
Add test template file
ShavinAnjithaAlpha 4cbf5ac
[Automated] Update the toml files
ShavinAnjithaAlpha 4ba0765
[Automated] Update the toml files
ShavinAnjithaAlpha 5615120
[Automated] Update the toml files
ShavinAnjithaAlpha c6d75a6
[Automated] Update the toml files
ShavinAnjithaAlpha bd94753
[Automated] Update the toml files
ShavinAnjithaAlpha de3be90
Add sanitization to the openapi spec
ShavinAnjithaAlpha 2c482c7
Regenerate the client with sanitization
ShavinAnjithaAlpha 9a44b15
Update the overview and quickstart
ShavinAnjithaAlpha d158134
Add tests for client
ShavinAnjithaAlpha d43f5ec
Update ballerina build config
ShavinAnjithaAlpha 6ee1035
Update ballerina build config
ShavinAnjithaAlpha 1741b24
Add license header
ShavinAnjithaAlpha 304bbae
Update docs and license file
ShavinAnjithaAlpha 35eda09
Update sanitization file
ShavinAnjithaAlpha ca2d40c
Change the test cases for improved code quality
ShavinAnjithaAlpha dd0ba15
Merge remote-tracking branch 'origin/main'
ShavinAnjithaAlpha 32fc34e
[Automated] Update the toml files
ShavinAnjithaAlpha 958575e
Fix issues in documentation and source files
ShavinAnjithaAlpha ee4fb66
[Automated] Update the toml files
ShavinAnjithaAlpha 7e16947
Add two examples
ShavinAnjithaAlpha b402a36
Format code and fix issues in docs
ShavinAnjithaAlpha 477b688
Update build files and example docs
ShavinAnjithaAlpha 24908e4
[Automated] Update the toml files
ShavinAnjithaAlpha 97943c1
Create a mock service for some endpoints
ShavinAnjithaAlpha 6be4f95
Fix issues and format docs and some source file
ShavinAnjithaAlpha b4a5d5f
Add auto-generated license header
ShavinAnjithaAlpha 27edf66
Rename example's readme files
ShavinAnjithaAlpha 7bbd1ff
Fix issue in example codes
ShavinAnjithaAlpha d2f463e
Add a new line to end of files
ShavinAnjithaAlpha 97a70a5
Restructure the test code
ShavinAnjithaAlpha aed5aa0
Change setup guide url path
ShavinAnjithaAlpha da7fda7
[Automated] Update the toml files
ShavinAnjithaAlpha 00e1c5d
Finish the mock service and add mock tests
ShavinAnjithaAlpha 138eb76
Change image URLs to GitHub URLs
ShavinAnjithaAlpha 73fa8d6
Change image URLs to GitHub URLs
ShavinAnjithaAlpha 1d2d4f4
Change image URLs
ShavinAnjithaAlpha 1a70da4
Modify the example codes
ShavinAnjithaAlpha 0bf20d4
Merge remote-tracking branch 'origin/main'
ShavinAnjithaAlpha 811cf48
Change arguments to main function
ShavinAnjithaAlpha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,3 +56,6 @@ build | |
|
|
||
| # Ignore Docker env file | ||
| docker.env | ||
|
|
||
| # Test config file | ||
| ballerina/tests/Config.toml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,161 @@ | |
|
|
||
| [//]: # (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.crm.obj.contacts offers APIs to connect and interact with the [Contact API](https://api.hubapi.com/crm/v3/objects/contacts) endpoints, specifically based on the [API Docs](https://developers.hubspot.com/docs/reference/api/crm/objects/contacts) | ||
|
|
||
| ## Setup guide | ||
|
|
||
| [//]: # (TODO: Add detailed steps to obtain credentials and configure the module.) | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To use the HubSpot connector, you must have access to the HubSpot API through a [HubSpot developer account](https://developers.hubspot.com/get-started) and a project under it. If you do not have a HubSpot Developer account, you can sign up for one [here](https://app.hubspot.com/signup-hubspot/developers?_ga=2.207749649.2047916093.1734412948-232493525.1734412948&step=landing_page). | ||
|
|
||
| ### Step 1: Create a HubSpot Developer Project | ||
|
|
||
| 1. Open the [HubSpot Developer Portal](https://app.hubspot.com/login/?loginRedirectUrl=https%3A%2F%2Fapp.hubspot.com%2Fsignup-hubspot%2Fdevelopers%3F_ga%3D2.269102326.624948025.1734413225-1764281074.1734413225%26step%3Dlanding_page) | ||
|
|
||
| 2. Click on the 'App' tab and select an existing project or create a new project for which you want API keys and Authentication Access. | ||
|
|
||
|  | ||
|
||
|
|
||
| In order to create a new poject, you must provide a public app name and a redirect url/s. Optionally you can add a app logo and a description for the app. | ||
|
|
||
|  | ||
|
|
||
| To add redirect url/s for the app, click the 'Auth' tab on top of the page, and navigate to 'Redirect URLs' section. | ||
|
|
||
|  | ||
|
|
||
|  | ||
|
|
||
| ### Setp 2. Obtain Client ID and Client Secret. | ||
|
|
||
| 1. After completing the project setup, you will be provided with your client id and client secret. Make sure to save the provided client id and client secret. | ||
|
|
||
|  | ||
|
|
||
| ### 2. Setup OAuth 2.0 Flow | ||
|
|
||
| Before proceeding with Quick start, ensure you ave obtained the Access Token and refresh Token using the following steps: | ||
|
|
||
| 1. Add necessaryscopes for your app based on API your using. Go to the relevate [API reference](https://developers.hubspot.com/beta-docs/reference/api), select the API you have and go through the operation. | ||
|
|
||
| You will see the scope has defined below way | ||
|
|
||
|  | ||
|
|
||
| 2. Obtained the authorization URL (Install URL) from the Auth Section under 'Sample install URL (OAuth)' section. It will be in this format: | ||
|
|
||
| ``` | ||
| https://app.hubspot.com/oauth/authorize?client_id=<client_id>&redirect_uri=<redirect_url>&scope=<scopes> | ||
| ``` | ||
| 3. Copy and paste the generated URL into your browser. This will redirect you to the HubSpot authorization page. | ||
|
|
||
|  | ||
|
|
||
| 4. Once you authorize, you will be redirected to your specified redirect URI with an authorization code in the URL. | ||
|
|
||
| **Note**: Store the authorization code and use it promptly as it expires quickly. | ||
|
|
||
| 5. Use the obtained authorization code to run the following curl command, replacing <your_client_id>, <your_redirect_url>, and <your_authorization_code> with your specific values: | ||
|
|
||
| - 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=<your_authorization_code>&redirect_uri=<your_redirect_url>&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=<your_authorization_code>&redirect_uri=<your_redirect_url>&client_id=<your_client_id>&client_secret=<your_client_secret>' | ||
| ``` | ||
|
|
||
| This command will return the access token and refresh token necessary for API calls. | ||
|
|
||
| ```json | ||
| { | ||
| "token_type": "bearer", | ||
| "refresh_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | ||
| "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | ||
| "expires_in": 1800 | ||
| } | ||
| ``` | ||
|
|
||
| 6. 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 Contact Connector` connector in your Ballerina application, update the `.bal` file as follows: | ||
|
|
||
| ### Step 1: Import the module | ||
|
|
||
| Import the `hubspot.crm.obj.contact` module. | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ````java | ||
| import ballerinax/hubspot.crm.obj.contact; | ||
| ```` | ||
|
|
||
| ### Step 2: Instantiate a new connector | ||
|
|
||
| 1. Create a Config.toml file and, configure the obtained credentials in the above steps as follows: | ||
|
|
||
| ````toml | ||
| [authConfig] | ||
| clientId = "<Client Id>" | ||
| clientSecret = "<Client Secret>" | ||
| refreshToken = "<Refresh Token>" | ||
| credentialBearer = "POST_BODY_BEARER" | ||
| ```` | ||
|
|
||
| 2. Create a `OAuth2RefreshTokenGrantConfig` with the obtained access token and initialize the connector with it. | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ````java | ||
| configurable OAuth2RefreshTokenGrantConfig & readonly authConfig = ?; | ||
|
|
||
| final hubspot.crm.obj.Contact:Client hubSpotContactClient = check new({ | ||
| auth: authConfig | ||
| }); | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```` | ||
|
|
||
| ### Step 3: Invoke the connector operation | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Now, utilize the available connector operations. | ||
|
|
||
| **Create a contact** | ||
|
|
||
| ````java | ||
| public function main() returns error? { | ||
| hubspot.crm.obj.contact:SimplePublicObject|error response = hubSpotContactClient->/.post({ | ||
| associations: [ | ||
| { | ||
| to: { | ||
| id: "1" | ||
| } | ||
| } | ||
| ], | ||
| objectWriteTraceId: "1", | ||
| properties: { | ||
| "sample_property": "sample value" | ||
| } | ||
| }); | ||
| } | ||
| ```` | ||
|
|
||
| ### Step 4: Run the Ballerina application | ||
|
|
||
| ````bash | ||
| bal run | ||
| ```` | ||
|
|
||
| ## Examples | ||
ShavinAnjithaAlpha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The `Ballerina HubSpot CRM Contacts Connector` connector provides practical examples illustrating usage in various scenarios. Explore these [examples](https://github.com/module-ballerinax-hubspot.crm.object.contacts/tree/main/examples/), covering the following use cases: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.