@hubspot/api-client
Advanced tools
Comparing version 3.2.2 to 3.2.3
@@ -124,16 +124,4 @@ # Changelog | ||
## [3.2.0] - 2021-01-26 | ||
### Added | ||
- automation.actions client | ||
## [3.2.1] - 2021-01-26 | ||
### Fixed | ||
- fix batch methods in `cms.blogs` API clients | ||
[unreleased]: https://github.com/HubSpot/hubspot-api-nodejs/compare/v3.2.1...HEAD | ||
[unreleased]: https://github.com/HubSpot/hubspot-api-nodejs/compare/v3.1.0...HEAD | ||
[1.0.0-beta]: https://github.com/HubSpot/hubspot-api-nodejs/releases/tag/v1.0.0-beta | ||
@@ -147,3 +135,1 @@ [1.1.0-beta]: https://github.com/HubSpot/hubspot-api-nodejs/releases/tag/v1.1.0-beta | ||
[3.1.0]: https://github.com/HubSpot/hubspot-api-nodejs/releases/tag/v3.1.0 | ||
[3.2.0]: https://github.com/HubSpot/hubspot-api-nodejs/releases/tag/v3.2.0 | ||
[3.2.1]: https://github.com/HubSpot/hubspot-api-nodejs/releases/tag/v3.2.1 |
{ | ||
"name": "@hubspot/api-client", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "NodeJS v3 [HubSpot API](https://developers.hubspot.com/docs/api/overview) SDK(Client) files and sample apps", | ||
@@ -8,8 +8,11 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"No test specified\"", | ||
"build": "tsc", | ||
"test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json", | ||
"prettier:check": "prettier --check {,**/}*.{js,ts}", | ||
"prettier:write": "prettier --write {,**/}*.{js,ts}", | ||
"lint": "tslint -p tsconfig.json && npm run prettier:check", | ||
"prepare": "npm run build" | ||
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"", | ||
"lint": "tslint -p tsconfig.json -e codegen", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run lint", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
@@ -26,3 +29,2 @@ "author": "HubSpot", | ||
"@types/bluebird": "^3.5.29", | ||
"@types/jasmine": "^3.6.2", | ||
"@types/lodash": "^4.14.149", | ||
@@ -40,5 +42,3 @@ "@types/node": "^12.12.21", | ||
"eslint-plugin-standard": "4.0.1", | ||
"jasmine": "^3.6.3", | ||
"prettier": "^1.19.1", | ||
"ts-node": "^9.1.1", | ||
"tslint": "^5.20.1", | ||
@@ -45,0 +45,0 @@ "tslint-config-prettier": "^1.18.0", |
154
README.md
# hubspot-api-nodejs | ||
NodeJS v3 [HubSpot API](https://developers.hubspot.com/docs/api/overview) SDK(Client) files and sample apps | ||
@@ -17,3 +16,3 @@ | ||
const hubspot = require('@hubspot/api-client') | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }) | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY}) | ||
``` | ||
@@ -50,6 +49,3 @@ | ||
```javascript | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
defaultHeaders: { 'My-header': 'test-example' }, | ||
}) | ||
const hubspotClient = new hubspot.Client({ accessToken: YOUR_ACCESS_TOKEN, defaultHeaders: { "My-header": "test-example" } }) | ||
``` | ||
@@ -61,8 +57,14 @@ | ||
```javascript | ||
const hubspotClient = new hubspot.Client() | ||
return hubspotClient.oauth.defaultApi | ||
.createToken('refresh_token', undefined, undefined, YOUR_CLIENT_ID, YOUR_CLIENT_SECRET, YOUR_REFRESH_TOKEN) | ||
.then((results) => { | ||
console.log(results.body) | ||
const hubspotClient = new hubspot.Client(); | ||
return hubspotClient.oauth.defaultApi.createToken( | ||
'refresh_token', | ||
undefined, | ||
undefined, | ||
YOUR_CLIENT_ID, | ||
YOUR_CLIENT_SECRET, | ||
YOUR_REFRESH_TOKEN | ||
) | ||
.then(results => { | ||
console.log(results.body); | ||
// this assigns the accessToken to the client, so your client is ready | ||
@@ -100,7 +102,8 @@ // to use | ||
It's possible to turn off rate limiting: | ||
```javascript | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
useLimiter: false, | ||
@@ -111,8 +114,8 @@ }) | ||
It's possible to turn on retry for failed requests with statuses 429 or 5xx. To turn on/off Configurable Retries use numberOfApiCallRetries option on Client instance creation. | ||
numberOfApiCallRetries could be set to a numberfrom 0 - 6. If numberOfApiCallRetries is set to a number greater than 0 it means that if any API Call receives ISE5xx this call will be retried after a delay 200 \* retryNumber ms and if 429 (Rate limit is exceeded) is returned for "TEN_SECONDLY_ROLLING" the call will be retried after a delay 10 sec. Number of retries will not exceed numberOfApiCallRetries value. | ||
numberOfApiCallRetries could be set to a numberfrom 0 - 6. If numberOfApiCallRetries is set to a number greater than 0 it means that if any API Call receives ISE5xx this call will be retried after a delay 200 * retryNumber ms and if 429 (Rate limit is exceeded) is returned for "TEN_SECONDLY_ROLLING" the call will be retried after a delay 10 sec. Number of retries will not exceed numberOfApiCallRetries value. | ||
```javascript | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
numberOfApiCallRetries: NumberOfRetries.Six, | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
numberOfApiCallRetries : NumberOfRetries.Six | ||
}) | ||
@@ -124,5 +127,5 @@ ``` | ||
```javascript | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
interceptors: [interceptorFn1, interceptorFn2], | ||
const hubspotClient = new hubspot.Client({ | ||
accessToken: YOUR_ACCESS_TOKEN, | ||
interceptors: [interceptorFn1, interceptorFn2] | ||
}) | ||
@@ -136,10 +139,9 @@ ``` | ||
```javascript | ||
hubspotClient.crm.contacts.basicApi | ||
.getPage(limit, after, properties, associations, archived) | ||
.then((results) => { | ||
console.log(results.body) | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
}) | ||
hubspotClient.crm.contacts.basicApi.getPage(limit, after, properties, associations, archived) | ||
.then(results => { | ||
console.log(results.body) | ||
}) | ||
.catch(err => { | ||
console.error(err) | ||
}) | ||
``` | ||
@@ -152,46 +154,21 @@ | ||
```javascript | ||
const contactObj = { | ||
const contactObj = { | ||
properties: { | ||
firstname: yourValue, | ||
lastname: yourValue, | ||
}, | ||
} | ||
lastname: yourValue | ||
} | ||
}; | ||
const companyObj = { | ||
properties: { | ||
domain: yourValue, | ||
name: yourValue, | ||
}, | ||
} | ||
name: yourValue | ||
} | ||
}; | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }) | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }); | ||
const createContactResponse = await hubspotClient.crm.contacts.basicApi.create(contactObj) | ||
const createCompanyResponse = await hubspotClient.crm.companies.basicApi.create(companyObj) | ||
await hubspotClient.crm.companies.associationsApi.create( | ||
createCompanyResponse.body.id, | ||
'contacts', | ||
createContactResponse.body.id, | ||
) | ||
await hubspotClient.crm.companies.associationsApi.create(createCompanyResponse.body.id, 'contacts', createContactResponse.body.id) | ||
``` | ||
### {EXAMPLE} Update multiple objects in batch mode | ||
```javascript | ||
const dealObj = { | ||
id: yourId, | ||
properties: { | ||
amount: yourValue, | ||
}, | ||
} | ||
const dealObj2 = { | ||
id: yourId, | ||
properties: { | ||
amount: yourValue, | ||
}, | ||
} | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }) | ||
await hubspotClient.crm.deals.batchApi.update({ inputs: [dealObj, dealObj2] }) | ||
``` | ||
### {EXAMPLE} Import Contacts: | ||
@@ -203,5 +180,5 @@ | ||
const hubspot = require('@hubspot/api-client') | ||
const fs = require('fs') | ||
const fs = require('fs'); | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }) | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }); | ||
const importRequest = { | ||
@@ -241,5 +218,5 @@ name: 'test_import', | ||
const hubspot = require('@hubspot/api-client') | ||
const fs = require('fs') | ||
const fs = require('fs'); | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }) | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY }); | ||
const importRequest = { | ||
@@ -300,3 +277,3 @@ name: 'test_import', | ||
const filterGroup = { filters: [filter] } | ||
const sort = JSON.stringify({ propertyName: 'createdate', direction: 'DESCENDING' }) | ||
const sort = JSON.stringify({ propertyName: 'createdate', direction: 'DESCENDING'}) | ||
const query = 'test' | ||
@@ -313,4 +290,4 @@ const properties = ['createdate', 'firstname', 'lastname'] | ||
limit, | ||
after, | ||
} | ||
after | ||
}; | ||
@@ -370,6 +347,6 @@ const result = await hubspotClient.crm.contacts.searchApi.doSearch(publicObjectSearchRequest) | ||
hubspotClient.apiRequest({ | ||
method: 'PUT', | ||
path: '/some/api/not/wrapped/yet', | ||
body: { key: 'value' }, | ||
}) | ||
method: 'PUT', | ||
path: '/some/api/not/wrapped/yet', | ||
body: { key: 'value' }, | ||
}) | ||
``` | ||
@@ -382,4 +359,4 @@ | ||
```typescript | ||
import * as hubspot from '@hubspot/api-client' | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY, developerApiKey: YOUR_DEVELOPER_API_KEY }) | ||
import * as hubspot from '@hubspot/api-client'; | ||
const hubspotClient = new hubspot.Client({ apiKey: YOUR_API_KEY, developerApiKey: YOUR_DEVELOPER_API_KEY }); | ||
``` | ||
@@ -389,25 +366,2 @@ | ||
Apache 2.0 | ||
## Contributing | ||
Install project dependencies with | ||
```bash | ||
npm install | ||
``` | ||
You can run the tests by executing: | ||
```bash | ||
npm run test | ||
``` | ||
You can check the TypeScript code by running: | ||
``` | ||
npm run lint | ||
``` | ||
If there is a linting error based on formatting, you can run the command below to auto-correct the formatting: | ||
``` | ||
npm run prettier:write | ||
``` | ||
MIT |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
17
32019
1
353