-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hubspot): [nan-1888] [nan-1900] Hubspot products sync and create…
…-property (#70) ## Describe your changes - Adds `products` sync - Adds `create-property` action ## Issue ticket number and link NAN-1888 NAN-1900 ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] External API requests have `retries` - [ ] Pagination is used where appropriate - [ ] The built in `nango.paginate` call is used instead of a `while (true)` loop - [ ] Third party requests are NOT parallelized (this can cause issues with rate limits) - [ ] If a sync requires metadata the `nango.yaml` has `auto_start: false` - [ ] If the sync is a `full` sync then `track_deletes: true` is set
- Loading branch information
1 parent
ad5ab48
commit a6f831c
Showing
20 changed files
with
1,031 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { NangoAction, CreatedProperty, CreatePropertyInput } from '../../models'; | ||
import { CreatePropertyInputSchema } from '../schema.js'; | ||
|
||
/** | ||
* Executes an action to create a custom property in the CRM. | ||
* It validates the input against the defined schema, logs any validation errors, | ||
* and then sends a POST request to create the custom properties if the input is valid. | ||
* @param nango - An instance of NangoAction used to interact with the Nango API and handle logging. | ||
* @param input - The input data for creating the custom property, validated by the CustomPropertyInputSchema. | ||
* @returns A promise that resolves with the result of the API call, which includes the details of the created custom property. | ||
* @throws An ActionError if the input validation fails. | ||
*/ | ||
export default async function runAction(nango: NangoAction, input: CreatePropertyInput): Promise<CreatedProperty> { | ||
const parsedInput = CreatePropertyInputSchema.safeParse(input); | ||
|
||
if (!parsedInput.success) { | ||
for (const error of parsedInput.error.errors) { | ||
await nango.log(`Invalid input provided to create custom property: ${error.message} at path ${error.path.join('.')}`, { level: 'error' }); | ||
} | ||
throw new nango.ActionError({ | ||
message: 'Invalid input provided to create custom property' | ||
}); | ||
} | ||
|
||
const inputData = parsedInput.data; | ||
|
||
const response = await nango.post({ | ||
// https://developers.hubspot.com/docs/api/crm/properties | ||
endpoint: `/crm/v3/properties/${inputData.objectType}`, | ||
data: inputData.data, | ||
retries: 10 | ||
}); | ||
|
||
return response.data; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { NangoAction, OptionalObjectType, PipelineOutput } from '../../models'; | ||
|
||
export default async function runAction(nango: NangoAction, input: OptionalObjectType): Promise<PipelineOutput> { | ||
const objectType = input?.objectType || 'deal'; | ||
|
||
const response = await nango.get({ | ||
// https://developers.hubspot.com/docs/api/crm/pipelines | ||
endpoint: `/crm/v3/pipelines/${objectType}`, | ||
retries: 10 | ||
}); | ||
|
||
const { data } = response; | ||
|
||
return { | ||
pipelines: data.results | ||
}; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"objectType": "companies", | ||
"data": { | ||
"hidden": false, | ||
"displayOrder": 1, | ||
"description": "string", | ||
"label": "My Company Property", | ||
"type": "enumeration", | ||
"formField": false, | ||
"groupName": "companyinformation", | ||
"name": "my_cool_company_property", | ||
"options": [ | ||
{ | ||
"label": "Option A", | ||
"value": "A", | ||
"hidden": false, | ||
"description": "Choice number one", | ||
"displayOrder": 1 | ||
}, | ||
{ | ||
"label": "Option B", | ||
"value": "B", | ||
"hidden": false, | ||
"description": "Choice number two", | ||
"displayOrder": 2 | ||
} | ||
], | ||
"hasUniqueValue": false, | ||
"fieldType": "select" | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"objectType": "companies", | ||
"data": { | ||
"hidden": false, | ||
"displayOrder": 1, | ||
"description": "string", | ||
"label": "My Company Property", | ||
"type": "enumeration", | ||
"formField": false, | ||
"groupName": "companyinformation", | ||
"name": "my_cool_company_property", | ||
"options": [ | ||
{ | ||
"label": "Option A", | ||
"value": "A", | ||
"hidden": false, | ||
"description": "Choice number one", | ||
"displayOrder": 1 | ||
}, | ||
{ | ||
"label": "Option B", | ||
"value": "B", | ||
"hidden": false, | ||
"description": "Choice number two", | ||
"displayOrder": 2 | ||
} | ||
], | ||
"hasUniqueValue": false, | ||
"fieldType": "select" | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"updatedAt": "2024-10-23T12:40:46.602Z", | ||
"createdAt": "2024-10-23T12:40:46.602Z", | ||
"name": "my_cool_company_property", | ||
"label": "My Company Property", | ||
"type": "enumeration", | ||
"fieldType": "select", | ||
"description": "string", | ||
"groupName": "companyinformation", | ||
"options": [ | ||
{ | ||
"label": "Option A", | ||
"value": "A", | ||
"description": "Choice number one", | ||
"displayOrder": 1, | ||
"hidden": false | ||
}, | ||
{ | ||
"label": "Option B", | ||
"value": "B", | ||
"description": "Choice number two", | ||
"displayOrder": 2, | ||
"hidden": false | ||
} | ||
], | ||
"createdUserId": "46062047", | ||
"updatedUserId": "46062047", | ||
"displayOrder": 1, | ||
"calculated": false, | ||
"externalOptions": false, | ||
"archived": false, | ||
"hasUniqueValue": false, | ||
"hidden": false, | ||
"modificationMetadata": { | ||
"archivable": true, | ||
"readOnlyDefinition": false, | ||
"readOnlyValue": false | ||
}, | ||
"formField": false, | ||
"dataSensitivity": "non_sensitive" | ||
} |
Oops, something went wrong.