Skip to content

Commit

Permalink
Update repo location
Browse files Browse the repository at this point in the history
This also fixes a few typos and formatting issues.

Co-Authored-By: Edward Loveall <[email protected]>
  • Loading branch information
MattMSumner and edwardloveall committed Dec 5, 2018
1 parent 5af0790 commit af4ec40
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 88 deletions.
121 changes: 73 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# node-hubspot
[![Build Status](https://api.travis-ci.org/brainflake/node-hubspot.svg)](https://travis-ci.org/brainflake/node-hubspot)
[![Code Climate](https://codeclimate.com/github/brainflake/node-hubspot/badges/gpa.svg)](https://codeclimate.com/github/brainflake/node-hubspot)
[![Test Coverage](https://codeclimate.com/github/brainflake/node-hubspot/badges/coverage.svg)](https://codeclimate.com/github/brainflake/node-hubspot/coverage)
[![Issue Count](https://codeclimate.com/github/brainflake/node-hubspot/badges/issue_count.svg)](https://codeclimate.com/github/brainflake/node-hubspot)
[![Dependencies](https://david-dm.org/brainflake/node-hubspot.svg)](https://david-dm.org/brainflake/node-hubspot)

[![Build Status](https://api.travis-ci.org/MadKudu/node-hubspot.svg)](https://travis-ci.org/MadKudu/node-hubspot)
[![Code Climate](https://codeclimate.com/github/MadKudu/node-hubspot/badges/gpa.svg)](https://codeclimate.com/github/MadKudu/node-hubspot)
[![Test Coverage](https://codeclimate.com/github/MadKudu/node-hubspot/badges/coverage.svg)](https://codeclimate.com/github/MadKudu/node-hubspot/coverage)
[![Issue Count](https://codeclimate.com/github/MadKudu/node-hubspot/badges/issue_count.svg)](https://codeclimate.com/github/MadKudu/node-hubspot)
[![Dependencies](https://david-dm.org/MadKudu/node-hubspot.svg)](https://david-dm.org/MadKudu/node-hubspot)

Javascript / node.js wrapper for the [HubSpot API](https://developers.hubspot.com/docs/overview)

## Upgrade to 1.0

Version 1.0 was released on 2017-08-23 and included breaking changes. See the [Changelog](./changelog.md) for details.
Version 1.0 was released on 2017-08-23 and included breaking changes. See the
[Changelog](./changelog.md) for details.

If you need help upgrading, please open an issue

## Installing
Expand All @@ -21,23 +24,25 @@ npm install hubspot
## Instantiate client

```javascript
const Hubspot = require('hubspot');
const hubspot = new Hubspot({ apiKey: 'abc' });
const Hubspot = require('hubspot')
const hubspot = new Hubspot({ apiKey: 'abc' })
```

You can also authenticate via token:

```javascript
const hubspot = new Hubspot({ accessToken: 'abc' });
const hubspot = new Hubspot({ accessToken: 'abc' })
```

To change the base url

```javascript
const hubspot = new Hubspot({ accessToken: 'abc', baseUrl: 'https://some-url' });
const hubspot = new Hubspot({ accessToken: 'abc', baseUrl: 'https://some-url' })
```

If you're an app developer, you can also instantiate a client with your app details and a refresh_token and obtain a new accessToken:
If you're an app developer, you can also instantiate a client with your app
details and a refresh_token and obtain a new accessToken:

```javascript
const hubspot = new Hubspot({
clientId: ...,
Expand All @@ -48,7 +53,10 @@ const hubspot = new Hubspot({
return hubspot.refreshAccessToken()
.then(results => {
console.log(results.access_token)
console.log(hubspot.accessToken) // this assigns the new accessToken to the client, so your client is ready to use

// this assigns the new accessToken to the client, so your client is ready
// to use
console.log(hubspot.accessToken)
return hubspot.contacts.get()
})
```
Expand All @@ -58,10 +66,12 @@ return hubspot.refreshAccessToken()
And then use the API method via:

```javascript
hubspot.contacts.get(options)
hubspot.contacts
.get(options)
.then(results => {
console.log(results)
}).catch(err => {
})
.catch(err => {
console.error(err)
})
```
Expand All @@ -70,11 +80,15 @@ or if you prefer callbacks:

```javascript
hubspot.contacts.get(function(err, results) {
if (err) { console.error(err) }
console.log(results);
});
if (err) {
console.error(err)
}
console.log(results)
})
```

## {EXAMPLE} Create Contact

```javascript
const contactObject = {
"properties":
Expand All @@ -87,17 +101,20 @@ const contactObject = {
const hubspot = new Hubspot({ apiKey: YOUR API KEY });
const hubspotContact = await hubspot.contacts.create(contactObj);
```
## {EXAMPLE} If you need to insert mulitple values. each value must have a semi colon after each value

## {EXAMPLE} If you need to insert multiple values

Each value must have a semi colon after each value

```json
{ "property": "foo", "value": "value1;value2;value3;value4" }
```

## API limits

HubSpot has relatively stringent API limits (40,000 per day by default).
To prevent from consuming it all-at-once, this library checks API quotas regularly and will fail requests if the total is too close to the max.
By default
HubSpot has relatively stringent API limits (40,000 per day by default). To
prevent from consuming it all-at-once, this library checks API quotas regularly
and will fail requests if the total is too close to the max. By default

## Available Methods

Expand All @@ -110,11 +127,13 @@ hubspot.companies.getRecentlyCreated(opts, cb)
hubspot.companies.getRecentlyModified(opts, cb)
hubspot.companies.getByDomain(domain, cb)
hubspot.companies.create(data, cb)
hubspot.companies.addContactToCompany(data, cb) // data = { companyId: 123, contactVid: 123 }
hubspot.companies.addContactToCompany(data, cb)
// data = { companyId: 123, contactVid: 123 }
hubspot.companies.getContactIds(id, options, cb)
hubspot.companies.getContacts(id, options, cb)
hubspot.companies.update(id, data, cb)
hubspot.companies.updateBatch(data, cb) // data = [{ objectId: 123, properties: [] }]
hubspot.companies.updateBatch(data, cb)
// data = [{ objectId: 123, properties: [] }]
hubspot.companies.delete(id, cb)
```

Expand All @@ -125,7 +144,9 @@ hubspot.companies.properties.get(query, cb) // query is optional
hubspot.companies.properties.getByName(name, cb)
hubspot.companies.properties.create(data, cb)
hubspot.companies.properties.update(name, data, cb)
hubspot.companies.properties.upsert(name, data) // not an official API, wrapper doing two API calls. Callbacks not supported at this time
hubspot.companies.properties.upsert(name, data)
// not an official API, wrapper doing two API calls. Callbacks not supported
// at this time.
```

### Company properties groups
Expand All @@ -134,7 +155,9 @@ hubspot.companies.properties.upsert(name, data) // not an official API, wrapper
hubspot.companies.properties.groups.get(query, cb) // query is optional
hubspot.companies.properties.groups.create(data, cb)
hubspot.companies.properties.groups.update(name, data, cb)
hubspot.companies.properties.groups.upsert(name, data) // not an official API, wrapper doing two API calls. Callbacks not supported at this time
hubspot.companies.properties.groups.upsert(name, data)
// not an official API, wrapper doing two API calls. Callbacks not supported at
// this time
```

### Contacts
Expand All @@ -148,7 +171,8 @@ hubspot.contacts.getByIdBatch(ids, cb)
hubspot.contacts.getByToken(utk, cb)
hubspot.contacts.update(id, data, cb)
hubspot.contacts.create(data, cb)
hubspot.contacts.createOrUpdateBatch(data, cb) // data = [{ vid/email: '', properties: [] }]
hubspot.contacts.createOrUpdateBatch(data, cb)
// data = [{ vid/email: '', properties: [] }]
hubspot.contacts.search(query, cb)
hubspot.contacts.getRecentlyCreated(cb)
hubspot.contacts.getRecentlyModified(cb)
Expand All @@ -163,10 +187,13 @@ hubspot.contacts.properties.get(cb)
hubspot.contacts.properties.getByName(name, cb)
hubspot.contacts.properties.create(data, cb)
hubspot.contacts.properties.update(name, data, cb)
hubspot.contacts.properties.upsert(name, data) // not an official API, wrapper doing two API calls. Callbacks not supported at this time
hubspot.contacts.properties.getGroups(cb) // => [ {name: '...', displayName: '...'}, ...]
hubspot.contacts.properties.createGroup({name, displayName}, cb)
hubspot.contacts.properties.updateGroup(name, {displayName}, cb)
hubspot.contacts.properties.upsert(name, data)
// not an official API, wrapper doing two API calls.
// Callbacks not supported at this time
hubspot.contacts.properties.getGroups(cb)
// => [ {name: '...', displayName: '...'}, ...]
hubspot.contacts.properties.createGroup({ name, displayName }, cb)
hubspot.contacts.properties.updateGroup(name, { displayName }, cb)
hubspot.contacts.properties.deleteGroup(name, cb)
hubspot.contacts.properties.delete(name, cb)
```
Expand All @@ -175,7 +202,7 @@ hubspot.contacts.properties.delete(name, cb)

```javascript
// more opts can be found at https://developers.hubspot.com/docs/methods/pages/get_pages
hubspot.pages.get(opts, cb); // eg: opts = {is_draft: false}
hubspot.pages.get(opts, cb) // eg: opts = {is_draft: false}
```

### Deals
Expand All @@ -200,7 +227,9 @@ hubspot.deals.properties.get(query, cb) // query is optional
hubspot.deals.properties.getByName(name, cb)
hubspot.deals.properties.create(data, cb)
hubspot.deals.properties.update(name, data, cb)
hubspot.deals.properties.upsert(name, data) // not an official API, wrapper doing two API calls. Callbacks not supported at this time
hubspot.deals.properties.upsert(name, data)
// not an official API, wrapper doing two API calls. Callbacks not supported at
// this time
```

### Deals properties groups
Expand All @@ -209,7 +238,9 @@ hubspot.deals.properties.upsert(name, data) // not an official API, wrapper doin
hubspot.deals.properties.groups.get(query, cb) // query is optional
hubspot.deals.properties.groups.create(data, cb)
hubspot.deals.properties.groups.update(name, data, cb)
hubspot.deals.properties.groups.upsert(name, data) // not an official API, wrapper doing two API calls. Callbacks not supported at this time
hubspot.deals.properties.groups.upsert(name, data)
// not an official API, wrapper doing two API calls. Callbacks not supported at
// this time
```

### Engagements
Expand Down Expand Up @@ -278,18 +309,7 @@ hubspot.broadcasts.get(opts, cb)
const params = {
client_id: 'your_client_id',
scopes: 'some scopes',
redirect_uri: 'take_me_to_the_ballpark'
}
const uri = hubspot.oauth.getAuthorizationUrl(params)
```

#### Obtain your authorization url

```javascript
const params = {
client_id: 'your_client_id',
scopes: 'some scopes',
redirect_uri: 'take_me_to_the_ballpark'
redirect_uri: 'take_me_to_the_ballpark',
}
const uri = hubspot.oauth.getAuthorizationUrl(params)
```
Expand All @@ -307,7 +327,8 @@ return hubspot.oauth.getAccessToken({
}).then(...)
```

You can also pass the constructor directly as parameters (although with a slighlty awkward case change)
You can also pass the constructor directly as parameters (although with a
slightly awkward case change)

```javascript
const params = {
Expand Down Expand Up @@ -337,8 +358,12 @@ MIT

### Tests

Tests are written using the HubSpot API sandbox. As such, resources get added and deleted all the time.
Don't harcode record values when fetching / updating / deleting (because those tend to disappear). Instead, fetch first an array of available records, then use of the returned ID in your test.
Tests are written using the HubSpot API sandbox. As such, resources get added
and deleted all the time.

Don't hard-code record values when fetching / updating / deleting (because those
tend to disappear). Instead, fetch first an array of available records, then use
of the returned ID in your test.

### Contributors

Expand Down
78 changes: 39 additions & 39 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
// Type definitions for hubspot 1.3.0
// Project: https://github.com/brainflake/node-hubspot

import { RequestCallback } from 'request';
import { RequestPromise } from 'request-promise';

import { Company } from './lib/typescript/company';
import { Contact } from './lib/typescript/contact';
import { Page } from './lib/typescript/page';
import { OAuth } from './lib/typescript/oauth';
import { Deal } from './lib/typescript/deal';
import { Engagement } from './lib/typescript/engagement';
import { Owner } from './lib/typescript/owner';
import { Pipeline } from './lib/typescript/pipeline';
import { List } from './lib/typescript/list';
import { File } from './lib/typescript/file';
import { Subscription } from './lib/typescript/subscription';
import { Campaign } from './lib/typescript/campaign';
import { Broadcast } from './lib/typescript/broadcast';
// Project: https://github.com/MadKudu/node-hubspot

import { RequestCallback } from 'request'
import { RequestPromise } from 'request-promise'

import { Company } from './lib/typescript/company'
import { Contact } from './lib/typescript/contact'
import { Page } from './lib/typescript/page'
import { OAuth } from './lib/typescript/oauth'
import { Deal } from './lib/typescript/deal'
import { Engagement } from './lib/typescript/engagement'
import { Owner } from './lib/typescript/owner'
import { Pipeline } from './lib/typescript/pipeline'
import { List } from './lib/typescript/list'
import { File } from './lib/typescript/file'
import { Subscription } from './lib/typescript/subscription'
import { Campaign } from './lib/typescript/campaign'
import { Broadcast } from './lib/typescript/broadcast'

interface BaseOptions {
baseUrl?: string;
baseUrl?: string
}

export interface ApiOptions extends BaseOptions {
apiKey: string;
apiKey: string
}

export interface AccessTokenOptions extends BaseOptions {
accessToken: string;
accessToken: string
}

export interface HubspotError {
status: string;
message: string;
correlationId: string;
requestId: string;
status: string
message: string
correlationId: string
requestId: string
}

declare class Hubspot {
constructor(options?: ApiOptions | AccessTokenOptions);
companies: Company;
contacts: Contact;
pages: Page;
deals: Deal;
engagements: Engagement;
owners: Owner;
oauth: OAuth;
pipelines: Pipeline;
lists: List;
files: File;
subscriptions: Subscription;
campaigns: Campaign;
broadcasts: Broadcast;
constructor(options?: ApiOptions | AccessTokenOptions)
companies: Company
contacts: Contact
pages: Page
deals: Deal
engagements: Engagement
owners: Owner
oauth: OAuth
pipelines: Pipeline
lists: List
files: File
subscriptions: Subscription
campaigns: Campaign
broadcasts: Broadcast
}

export default Hubspot
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git://github.com/brainflake/node-hubspot.git"
"url": "git://github.com/MadKudu/node-hubspot.git"
},
"keywords": [
"hubspot"
Expand Down

0 comments on commit af4ec40

Please sign in to comment.