0.0.2 • Published 4 years ago

helpscout-v2 v0.0.2

Weekly downloads
4
License
ISC
Repository
-
Last release
4 years ago

Unofficial HelpScout SDK for HelpScout API v2

This is my very first SDK integrated with HelpScout API, please feel free to use. If you have questions or issues, please feel free to open a new issue on this repository.

NPM

npm i --save helpscout-v2

How to use

const helpscout = require('helpscout-v2')(options);

Parameters


All parameters for options are listed by below.

ParameterDescription
client_idA hash string which is generated by HelpScout (App ID)
client_secretA hash string which is generated by HelpScout (App Secret)
access_tokenA hash string which can be got it by authentication function.

Token


  • Authentication: helpscout.token.authenticate()
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  const token = await helpscout.token.authenticate();
  // Get a result
  console.log(token);
}catch(ex) {
  // Catch an error
  console.log(ex);
};
  • Refresh Access Token: helpscout.token.refreshAccessToken(options)
ParameterDescription
refresh_tokenA hash string which can be got it by authentication function.
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  const refresh_token = "..................";
  const token = await helpscout.token.refreshAccessToken({  refresh_token });
  // Get a result
  console.log(token);
}catch(ex) {
  // Catch an error
  console.log(ex);
};

Mailbox


  • List mailboxes: helpscout.mailbox.get([id ,options])

id | Parameter | Description | |-------------|-------------| | id (optional) | A mailbox id |

options | Parameter | Description | |-------------|-------------| | access_token (optional) | (Override) A hash string which can be got it by authentication function. |

// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  // List mailboxes
  const mailboxes = await helpscout.mailbox.get();
  // Get a result
  console.log(mailboxes);
}catch(ex) {
  // Catch an error
  console.log(ex);
};
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  // Get information from mailbox id `1`
  const mailbox = await helpscout.mailbox.get(1);
  // Get a result
  console.log(mailbox);
}catch(ex) {
  // Catch an error
  console.log(ex);
};
  • Get mailbox folders: helpscout.mailbox.getFolders(id ,options)

id | Parameter | Description | |-------------|-------------| | id | A mailbox id |

options | Parameter | Description | |-------------|-------------| | access_token (optional) | (Override) A hash string which can be got it by authentication function. |

// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  // List mailboxes
  const mailboxes = await helpscout.mailbox.getFolders(1);
  // Get a result
  console.log(mailboxes);
}catch(ex) {
  // Catch an error
  console.log(ex);
};

Conversation

options

ParameterDescription
mailboxFilters conversations from a specific mailbox id. Use comma separated values for more mailboxes: ?mailbox=123,456
folderFilters conversations from a specific folder id: ?folder=993
statusFilter conversation by status (defaults to active): activeopenclosedpendingspamall
tagFilter conversation by tags. Use comma separated values for more tags that: ?tag=red,blue
assigned_toFilters conversations by assignee id: ?assigned_to=1771
modifiedSinceFilters conversations modified after this timestamp - ISO 8061 date time
numberLooks up conversation by conversation number
sortFieldSorts the result by specified field: createdAtcustomerEmailcustomerNamemailboxidmodifiedAtnumberscorestatussubject
sortOrderSort order, either desc or asc, default is desc
queryAdvanced search query. If you use other filtering request parameters, they will be combined with AND operator.For example ?mailbox=567&query=tag:fire effectively means mailbox=567 AND tag=fire.
pagePage number
// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  // List conversations
  const conversations = await helpscout.conversation.list();
  // Get a result
  console.log(conversations);
}catch(ex) {
  // Catch an error
  console.log(ex);
};

id | Parameter | Description | |-------------|-------------| | id (optional) | A conversation id |

options | Parameter | Description | |-------------|-------------| | access_token (optional) | (Override) A hash string which can be got it by authentication function. |

// import `helpscout-v2` and pass your `options` value.
const helpscout = require('helpscout-v2')(options);
try {
  // Get a conversation
  const conversation = await helpscout.conversation.get(123);
  // Get a result
  console.log(conversation);
}catch(ex) {
  // Catch an error
  console.log(ex);
};