Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pcothenet committed Oct 8, 2019
2 parents 8476c1a + cebe7bd commit 6a4053a
Show file tree
Hide file tree
Showing 22 changed files with 737 additions and 206 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ hubspot.contacts.properties.deleteGroup(name)
hubspot.contacts.properties.delete(name)
```

### CRM associations

```javascript
hubspot.crm.associations.create(data)
hubspot.crm.associations.createBatch(data)
hubspot.crm.associations.delete(data)
hubspot.crm.associations.deleteBatch(data)
// not an official API, wrapper doing two API calls. Callbacks not supported at
// this time
```

### Pages

```javascript
Expand All @@ -217,6 +228,7 @@ hubspot.deals.getById(id)
hubspot.deals.getAssociated(objectType, objectId, opts)
hubspot.deals.deleteById(id)
hubspot.deals.updateById(id, data)
hubspot.deals.updateBatch(data)
hubspot.deals.create(data)
hubspot.deals.associate(id, objectType, associatedObjectId)
hubspot.deals.removeAssociation(id, objectType, associatedObjectId)
Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Before submitting a pull request, please make sure the following is done:

1. Fork the repository and create your branch from master.
2. Run `npm build`. This will:
2. Run `npm run build`. This will:
1. Run `npm install` in the repository root.
2. Ensure the test suite passes with `npm test`.
3. Format your code with prettier and eslint using `npm run lint`.
Expand Down
24 changes: 21 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,35 @@ import { File } from './lib/typescript/file'
import { Subscription } from './lib/typescript/subscription'
import { Campaign } from './lib/typescript/campaign'
import { Broadcast } from './lib/typescript/broadcast'
import { CRM } from './lib/typescript/crm'
import { Emails } from './lib/typescript/emails'


interface BaseOptions {
baseUrl?: string
}

export interface ApiOptions extends BaseOptions {
export interface BottleneckOptions {
maxConcurrent?: number | null;
minTime?: number;
highWater?: number | null;
reservoir?: number | null;
reservoirRefreshInterval?: number | null;
reservoirRefreshAmount?: number | null;
reservoirIncreaseInterval?: number | null;
reservoirIncreaseAmount?: number | null;
reservoirIncreaseMaximum?: number | null;
[key: string]: any;
}

export interface LimiterOptions {
limiter?: BottleneckOptions
}

export interface ApiOptions extends BaseOptions, LimiterOptions {
apiKey: string
}

export interface AccessTokenOptions extends BaseOptions {
export interface AccessTokenOptions extends BaseOptions, LimiterOptions {
accessToken: string
}

Expand Down Expand Up @@ -63,6 +80,7 @@ declare class Hubspot {
subscriptions: Subscription
campaigns: Campaign
broadcasts: Broadcast
crm: CRM
emails: Emails
}

Expand Down
4 changes: 3 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Broadcast = require('./broadcast')
const Campaign = require('./campaign')
const Company = require('./company')
const Contact = require('./contact')
const CRM = require('./crm')
const Page = require('./page')
const Deal = require('./deal')
const Engagement = require('./engagement')
Expand Down Expand Up @@ -38,7 +39,7 @@ class Client extends EventEmitter {
typeof options.maxUsePercent !== 'undefined'
? options.maxUsePercent
: MAX_USE_PERCENT_DEFAULT
this.baseUrl = options.baseUrl || 'http://api.hubapi.com'
this.baseUrl = options.baseUrl || 'https://api.hubapi.com'
this.apiTimeout = options.timeout || API_TIMEOUT
this.apiCalls = 0
this.on('apiCall', params => {
Expand Down Expand Up @@ -75,6 +76,7 @@ class Client extends EventEmitter {
this.timelines = new Timeline(this)
this.subscriptions = new Subscription(this)
this.workflows = new Workflow(this)
this.crm = new CRM(this)
}

requestStats() {
Expand Down
4 changes: 2 additions & 2 deletions lib/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Company {

getByDomain(domain) {
return this.client._request({
method: 'GET',
path: '/companies/v2/companies/domain/' + domain,
method: 'POST',
path: `/companies/v2/domains/${domain}/companies`,
})
}

Expand Down
10 changes: 10 additions & 0 deletions lib/crm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Associations = require('./crm_association')

class CRM {
constructor(client) {
this.client = client
this.associations = new Associations(this.client)
}
}

module.exports = CRM
39 changes: 39 additions & 0 deletions lib/crm_association.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class Associations {
constructor(client) {
this.client = client
}

create(data) {
return this.client._request({
method: 'PUT',
path: '/crm-associations/v1/associations',
body: data,
})
}

createBatch(data) {
return this.client._request({
method: 'PUT',
path: '/crm-associations/v1/associations/create-batch',
body: data,
})
}

delete(data) {
return this.client._request({
method: 'PUT',
path: '/crm-associations/v1/associations/delete',
body: data,
})
}

deleteBatch(data) {
return this.client._request({
method: 'PUT',
path: '/crm-associations/v1/associations/delete-batch',
body: data,
})
}
}

module.exports = Associations
8 changes: 8 additions & 0 deletions lib/deal.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ class Deal {
})
}

updateBatch(data) {
return this.client._request({
method: 'POST',
path: '/deals/v1/batch-async/update',
body: data,
})
}

create(data) {
return this.client._request({
method: 'POST',
Expand Down
7 changes: 7 additions & 0 deletions lib/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class OAuth {
return results
})
}

getPortalInfo() {
return this.client._request({
method: 'GET',
path: `/oauth/v1/access-tokens/${this.client.accessToken}`
})
}
}

module.exports = OAuth
6 changes: 3 additions & 3 deletions lib/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Timeline {
}

createEventType(applicationId, userId, data) {
data['applicationId'] = data['applicationId'] || applicationId
data.applicationId = data.applicationId || applicationId
const parameters = {
method: 'POST',
path: `/integrations/v1/${applicationId}/timeline/event-types?userId=${userId}`,
Expand All @@ -16,7 +16,7 @@ class Timeline {
}

updateEventType(applicationId, eventTypeId, data) {
data['applicationId'] = data['applicationId'] || applicationId
data.applicationId = data.applicationId || applicationId
const parameters = {
method: 'PUT',
path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`,
Expand All @@ -37,7 +37,7 @@ class Timeline {
}

updateEventTypeProperty(applicationId, eventTypeId, propertyId, data) {
data['id'] = data['id'] || propertyId
data.id = data.id || propertyId
const parameters = {
method: 'PUT',
path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`,
Expand Down
2 changes: 1 addition & 1 deletion lib/typescript/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare class Contact {

getRecentlyModified(opts: {}): RequestPromise

createOrUpdate(email: string, data: any[]): RequestPromise
createOrUpdate(email: string, data: {}): RequestPromise

delete(id: number): RequestPromise

Expand Down
7 changes: 7 additions & 0 deletions lib/typescript/crm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Associations } from './crm_associations'

declare class CRM {
associations: Associations
}

export { CRM }
20 changes: 20 additions & 0 deletions lib/typescript/crm_associations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { RequestPromise } from 'request-promise'

export interface IHubspotCRMAssociation {
fromObjectId: number
toObjectId: number
category: string
definitionId: number
}

declare class Associations {
create(data: IHubspotCRMAssociation): RequestPromise

createBatch(data: IHubspotCRMAssociation[]): RequestPromise

delete(data: IHubspotCRMAssociation): RequestPromise

deleteBatch(data: IHubspotCRMAssociation[]): RequestPromise
}

export { Associations }
2 changes: 2 additions & 0 deletions lib/typescript/deal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ declare class Deal {

create(data: {}): RequestPromise

updateBatch(data: {}[]): RequestPromise

associate(
id: number,
objectType: string,
Expand Down
Loading

0 comments on commit 6a4053a

Please sign in to comment.