Namespace: hs/deals

hs/deals

A collection of methods related to the Deals API

Methods

hs/deals.batchUpdate (updates)Promise asyncstatic

Update a group of deals

Name Type Description
updates array

Array of objects. objectId corresponds with a dealId. See Example below.

Returns:
Type Description
Promise If successful the promise will resolve with { updated: true }. Otherwise the promise will resolve with an error message.
Example
const hs = new HubspotClient(props);
const updates = [{
 "objectId": 93630457,
 "properties": [
   {
     "name": "dealname",
     "value": "Updated Deal Name"
   },
   {
     "name": "dealname",
     "value": "Updated Deal Name"
   }
 ]},
 {
 "objectId": 26448234,
 "properties": [
   {
     "name": "amount",
     "value": "2000"
   }
 ]
}]);
hs.deals.batchUpdate(updates).then(response => console.log(response));

hs/deals.createOrUpdate (opts)Promise asyncstatic

Create or update a deal

Name Type Description
opts object
Properties:
Name Type Description
opts.id int
opts.properties array
opts.associations array
opts.includePropertyVersions boolean
Returns:
Type Description
Promise
Example
const hs = new HubspotClient(props);
const updatedDealOpts = {
  id:93630457,
  properties: [
  {
    value: 'Update Deal Name',
    name: 'dealname'
  },
  {
    value: '200000',
    name: 'amount'
  }
]};
hs.deals.createOrUpdate(updatedDealOpts).then(response => console.log(response));
const newDealOpts = {
associations: {
  associatedCompanyIds: 53333385
},
properties: [
  {
    value: 'Big Deal',
    name: 'dealname'
  },
  {
    value: 'appointmentscheduled',
    name: 'dealstage'
  },
  {
    value: 'default',
    name: 'pipeline'
  },
  {
    value: 1409443200000,
    name: 'closedate'
  },
  {
    value: '60000',
    name: 'amount'
  },
  {
    value: 'newbusiness',
    name: 'dealtype'
  }
]
};
hs.deals.createOrUpdate(newDealOpts).then(response => console.log(response));

hs/deals.getAll (opts)Promise asyncstatic

Get all deals

Name Type Description
opts object
Properties:
Name Type Description
opts.limit int
opts.offset int
opts.properties array
opts.propertiesWithHistory array
Returns:
Type Description
Promise
Example
const hs = new HubspotClient(props);
hs.deals.getRecentlyCreated({
  limit: 2,
  offset: 12356,
  properties: ['dealname', 'pipeline'],
  propertiesWithHistory: ['dealstage']
}).then(response => console.log(response));

hs/deals.getById (id, properties)Promise asyncstatic

Get deal by ID

Name Type Description
id int

The id of the deal to retrieve

properties object

Optional extra properties to add to the request - see developer docs

Returns:
Type Description
Promise
Example
const hs = new HubspotClient(props);
hs.deals.getById(123412313).then(response => console.log(response))

hs/deals.getRecentlyCreated (opts)Promise asyncstatic

Get recently created deals

Name Type Description
opts object
Properties:
Name Type Description
opts.count int
opts.offset int
opts.since int
opts.includePropertyVersions boolean
Returns:
Type Description
Promise
Example
const hs = new HubspotClient(props);
hs.deals.getRecentlyCreated({
  count: 50,
  offset: 5,
  includePropertyVersions: true,
  since: 1463680280365
}).then(response => console.log(response));