helpscout-docs
v0.2.3
Published
HelpScout Docs API client for Node.js
Downloads
13
Readme
helpscout-docs
HelpScout Docs API client for Node.js
Installation
$ npm install helpscout-docs
Usage
var HelpScoutDocs = require('helpscout-docs');
var apiKey = '{your api key}';
var hsdocs = new HelpScoutDocs(apiKey);
// get all collections
hsdocs.collections.getAll(function(err, result){
console.log(result);
});
All available methods are listed below
API Documentation
After module initialization:
var hsdocs = new HelpScoutDocs('{your api key}');
hsdocs
object has following methods to perform API calls:
Notice
All methods accept "error-first" callback function. In case of error, callback will be called with error message in first parameter, otherwise JSON result of API call will be passed as second parameter.
Some methods require data to pass. Provide object with data as first argument (see code examples).
Articles
- List Articles
hsdocs.articles.getAllByCollection({id:'{collectionId}'}, function(err, result){});
// or
hsdocs.articles.getAllByCategory({id:'{categoryId}'}, function(err, result){});
- Search Articles
hsdocs.articles.search({
fields:{
query: 'query string'
}
}, function(err, result){});
- List Related Articles
hsdocs.articles.getRelated({id:'{articleId}'}, function(err, result){});
- List Revisions
hsdocs.articles.getRevisions({id:'{articleId}'}, function(err, result){});
- Get Article
hsdocs.articles.get({id:'{articleId or articleNumber}'}, function(err, result){});
- Get Revision
hsdocs.articles.getRevision({id:'{revisionId}'}, function(err, result){});
- Create Article
hsdocs.articles.create({
fields:{
collectionId: '{collectionId}',
name: 'article name',
text: 'article text'
}
}, function(err, result){});
- Update Article
hsdocs.articles.update({
id: '{articleId}',
fields:{
name: 'article name',
text: 'article text'
}
}, function(err, result){});
- Upload Article
hsdocs.articles.upload({
fields:{
collectionId: '{collectionId}',
file: 'file data'
}
}, function(err, result){});
- Update View Count
hsdocs.articles.updateViewCount({
id: 'articleId',
fields:{
count: 42
}
}, function(err, result){});
- Delete Article
hsdocs.articles.delete({id:'{articleId}'}, function(err, result){});
- Save Article Draft
hsdocs.articles.saveDraft({
id: 'articleId',
fields:{
text: 'article text'
}
}, function(err, result){});
- Delete Article Draft
hsdocs.articles.deleteDraft({id:'{articleId}'}, function(err, result){});
Assets
- Create Article Asset
hsdocs.assets.createArticleAsset({
fields:{
articleId: '{articleId}',
assetType: 'attachment',
file: 'file data'
}
}, function(err, result){});
- Create Settings Asset
hsdocs.assets.createSettingsAsset({
fields:{
assetType: 'favicon',
file: 'file data'
}
}, function(err, result){});
Categories
- List Categories
hsdocs.categories.getAllByCollection({id:'{collectionId}'}, function(err, result){});
- Get Category
hsdocs.categories.get({id:'{categoryId or categoryNumber}'}, function(err, result){});
- Create Category
hsdocs.categories.create({
fields:{
collectionId: '{collectionId}',
name: 'category name'
}
}, function(err, result){});
- Update Category
hsdocs.categories.update({
id: '{categoryId}',
fields:{
name: 'category name'
}
}, function(err, result){});
- Update Category Order
hsdocs.categories.updateOrder({
id: '{collectionId}',
fields:{
categories: [
{
id: '{categoryId}',
order: 1
},
{
id: '{categoryId}',
order: 2
},
}
}
}, function(err, result){});
- Delete Category
hsdocs.categories.delete({id:'{categoryId}'}, function(err, result){});
Collections
- List Collections
hsdocs.collections.getAll(function(err, result){});
- Get Collection
hsdocs.collections.get({id:'{collectionId or collectionNumber}'}, function(err, result){});
- Create Collection
hsdocs.collections.create({
fields:{
siteId: '{siteId}',
name: 'collection name'
}
}, function(err, result){});
- Update Collection
hsdocs.collections.update({
id: '{collectionId}',
fields:{
name: 'collection name'
}
}, function(err, result){});
- Delete Collection
hsdocs.collections.delete({id:'{collectionId}'}, function(err, result){});
Redirects
- List Redirects
hsdocs.redirects.getAllBySite({id:'{siteId}'}, function(err, result){});
- Get Redirect
hsdocs.redirects.get({id:'{redirectId}'}, function(err, result){});
- Find Redirect
hsdocs.redirects.find({
fields: {
url: '/some/path/123',
siteId: '{siteId}'
}
}, function(err, result){});
- Create Redirect
hsdocs.redirects.create({
fields:{
siteId: '{siteId}',
urlMapping: '/some/path/123',
redirect: 'http://redirect.to/'
}
}, function(err, result){});
- Update Redirect
hsdocs.redirects.update({
id: '{redirectId}',
fields:{
siteId: '{siteId}',
urlMapping: '/some/path/123',
redirect: 'http://redirect.to/'
}
}, function(err, result){});
- Delete Redirect
hsdocs.redirects.delete({id:'{redirectId}'}, function(err, result){});
Sites
- List Sites
hsdocs.sites.getAll(function(err, result){});
- Get Site
hsdocs.sites.get({id:'{siteId}'}, function(err, result){});
- Create Site
hsdocs.sites.create({
fields:{
subDomain: 'some-subdomain',
title: 'site title'
}
}, function(err, result){});
- Update Site
hsdocs.sites.update({
id: '{siteId}',
fields:{
subDomain: 'some-subdomain',
title: 'site title'
}
}, function(err, result){});
- Transfer Site
hsdocs.sites.transfer({
id: '{siteId}',
fields:{
destinationApiKey: '{another account Docs API key}'
}
}, function(err, result){});
- Delete Site
hsdocs.sites.delete({id:'{siteId}'}, function(err, result){});
See full Help Scout Docs API description on official website: http://developer.helpscout.net/docs-api/