From af4ec40f5bfd416c3cce1e69ddf37e3a29fca3a2 Mon Sep 17 00:00:00 2001 From: Matthew Sumner Date: Tue, 4 Dec 2018 16:25:55 -0500 Subject: [PATCH] Update repo location This also fixes a few typos and formatting issues. Co-Authored-By: Edward Loveall --- README.md | 121 +++++++++++++++++++++++++++++++-------------------- index.d.ts | 78 ++++++++++++++++----------------- package.json | 2 +- 3 files changed, 113 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index bffe550..d978151 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: ..., @@ -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() }) ``` @@ -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) }) ``` @@ -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": @@ -87,7 +101,10 @@ 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" } @@ -95,9 +112,9 @@ const contactObject = { ## 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 @@ -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) ``` @@ -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 @@ -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 @@ -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) @@ -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) ``` @@ -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 @@ -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 @@ -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 @@ -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) ``` @@ -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 = { @@ -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 diff --git a/index.d.ts b/index.d.ts index cb537c5..62f02d9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 diff --git a/package.json b/package.json index 7692206..0ec8c63 100644 --- a/package.json +++ b/package.json @@ -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"