Skip to content

Commit

Permalink
Merge pull request #32 from NangoHQ/hubspot-deals
Browse files Browse the repository at this point in the history
feat(hubspot-groundwork): add deals and fetch properties to make it easier to work with
  • Loading branch information
khaliqgant authored Oct 3, 2024
2 parents 66ac9a3 + a35cdc3 commit e832464
Show file tree
Hide file tree
Showing 16 changed files with 10,669 additions and 506 deletions.
85 changes: 80 additions & 5 deletions flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2341,36 +2341,81 @@ integrations:
Fetches a list of service tickets from Hubspot
output: HubspotServiceTicket
sync_type: incremental
endpoint: GET /hubspot/service-tickets
endpoint: GET /service-tickets
contacts:
runs: every day
description: |
Fetches a list of contacts from Hubspot
output: HubspotContact
sync_type: full
endpoint: GET /hubspot/contacts
endpoint: GET /contacts
owners:
runs: every day
description: |
Fetches a list of owners from Hubspot
output: HubspotOwner
sync_type: full
endpoint: GET /hubspot/owner
endpoint: GET /owners
users:
runs: every day
description: |
Fetches a list of users from Hubspot
output: HubspotUser
sync_type: full
endpoint: GET /hubspot/user
endpoint: GET /users
knowledge-base:
runs: every day
description: |
Fetches a list of knowledge base from Hubspot
output: HubspotKnowledgeBase
sync_type: full
endpoint: GET /hubspot/knowledge-base
endpoint: GET /knowledge-base
actions:
fetch-properties:
description: Fetch the properties of a specified object
input: InputProperty
output: PropertyResponse
endpoint: GET /properties
create-deal:
description: Creates a deal in Hubspot
output: CreatedDeal
endpoint: POST /deals
input: CreateDeal
scopes:
- crm.objects.deals.write
models:
InputProperty:
name: string
PropertyResponse:
result: Property
Property:
updatedAt: string
createdAt: string
name: string
label: string
type: string
fieldType: string
description: string
groupName: string
options: Option[],
displayOrder: number
calculated: boolean
externalOptions: boolean
hasUniqueValue: boolean
hidden: boolean
hubspotDefined: boolean
showCurrencySymbol: boolean
modificationMetadata:
archivable: boolean
readOnlyDefinition: boolean
readOnlyValue: boolean
formField: boolean
dataSensitivity: string
Option:
label: string
value: string
displayOrder: number
hidden: boolean
HubspotServiceTicket:
id: integer
createdAt: date
Expand Down Expand Up @@ -2413,6 +2458,36 @@ integrations:
first_name: string
last_name: string
email: string
CreateDeal:
properties:
dealname: string
__string: any
DealDefaultProperties:
createdate: string
days_to_close: string
dealname: string
hs_closed_amount: string
hs_closed_amount_in_home_currency: string
hs_closed_won_count: string
hs_createdate: string
hs_days_to_close_raw: string
hs_deal_stage_probability_shadow: string
hs_is_closed_lost: string
hs_is_closed_won: string
hs_is_deal_split: string
hs_lastmodifieddate: string
hs_object_id: string
hs_object_source: string
hs_object_source_id: string
hs_object_source_label: string
hs_projected_amount: string
hs_projected_amount_in_home_currency: string
CreatedDeal:
id: string
properties: DealDefaultProperties
createdAt: string
updatedAt: string
archived: boolean
instantly:
actions:
set-campaign-name:
Expand Down
13 changes: 13 additions & 0 deletions integrations/hubspot/actions/create-deal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { NangoAction, ProxyConfiguration, CreateDeal, CreatedDeal } from '../../models';

export default async function runAction(nango: NangoAction, input: CreateDeal): Promise<CreatedDeal> {
const config: ProxyConfiguration = {
// https://developers.hubspot.com/docs/api/crm/deals
endpoint: 'crm/v3/objects/deals',
data: input,
retries: 10
};
const response = await nango.post(config);

return response.data;
}
18 changes: 18 additions & 0 deletions integrations/hubspot/actions/fetch-properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { NangoAction, ProxyConfiguration, PropertyResponse, InputProperty } from '../../models';

export default async function runAction(nango: NangoAction, input: InputProperty): Promise<PropertyResponse> {
if (!input.name) {
throw new nango.ActionError({
message: 'An object name must be passed in to look up the properties'
});
}

const config: ProxyConfiguration = {
// https://developers.hubspot.com/docs/api/crm/deals
endpoint: `crm/v3/properties/${input.name}`,
retries: 10
};
const response = await nango.get(config);

return response.data;
}
5 changes: 5 additions & 0 deletions integrations/hubspot/fixtures/create-deal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"properties": {
"dealname": "Test deal 1"
}
}
3 changes: 3 additions & 0 deletions integrations/hubspot/fixtures/fetch-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "deals"
}
5 changes: 5 additions & 0 deletions integrations/hubspot/mocks/create-deal/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"properties": {
"dealname": "Test deal 1"
}
}
27 changes: 27 additions & 0 deletions integrations/hubspot/mocks/create-deal/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": "20858667708",
"properties": {
"createdate": "2024-10-02T19:29:34.520Z",
"days_to_close": "0",
"dealname": "Test deal 1",
"hs_closed_amount": "0",
"hs_closed_amount_in_home_currency": "0",
"hs_closed_won_count": "0",
"hs_createdate": "2024-10-02T19:29:34.520Z",
"hs_days_to_close_raw": "0",
"hs_deal_stage_probability_shadow": "0",
"hs_is_closed_lost": "false",
"hs_is_closed_won": "false",
"hs_is_deal_split": "false",
"hs_lastmodifieddate": "2024-10-02T19:29:34.520Z",
"hs_object_id": "20858667708",
"hs_object_source": "INTEGRATION",
"hs_object_source_id": "3997414",
"hs_object_source_label": "INTEGRATION",
"hs_projected_amount": "0",
"hs_projected_amount_in_home_currency": "0"
},
"createdAt": "2024-10-02T19:29:34.520Z",
"updatedAt": "2024-10-02T19:29:34.520Z",
"archived": false
}
3 changes: 3 additions & 0 deletions integrations/hubspot/mocks/fetch-properties/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "deals"
}
Loading

0 comments on commit e832464

Please sign in to comment.