Official Helpful API library client for node.js
This library is generated by alpaca
Make sure you have npm installed.
$ npm install helpful
Works with [ 0.8 / 0.9 / 0.10 / 0.11 ]
var helpful = require('helpful');
// Then we instantiate a client (as shown below)
Using this api without authentication gives an error
var auth = { username: 'pksunkara', password: 'password' };
var client = helpful.client(auth, clientOptions);
var client = helpful.client('1a2b3', clientOptions);
var client = helpful.client({
client_id: '09a8b7',
client_secret: '1a2b3'
}, clientOptions);
The following options are available while instantiating a client:
- base: Base url for the api
- api_version: Default version of the api (to be used in url)
- user_agent: Default user-agent for all requests
- headers: Default headers for all requests
- request_type: Default format of the request body
All the callbacks provided to an api call will receive the response as shown below
// You can also omit the 'methodOptions' param below
client.klass('args').method('args', methodOptions, function (err, response) {
if (err) console.log(err);
response.code;
// >>> 200
response.headers;
// >>> {'x-server': 'apache'}
}
When the response sent by server is json, it is decoded into a hash
response.body;
// >>> {'user': 'pksunkara'}
The following options are available while calling a method of an api:
- api_version: Version of the api (to be used in url)
- headers: Headers for the request
- query: Query parameters for the url
- body: Body of the request
- request_type: Format of the request body
Set request_type in options to modify the body accordingly
When the value is set to raw, don't modify the body at all.
body = 'username=pksunkara';
// >>> 'username=pksunkara'
When the value is set to json, JSON encode the body.
body = {'user': 'pksunkara'};
// >>> '{"user": "pksunkara"}'
These are like organizations which use Helpful.
var accounts = client.accounts();
All the accounts the user has access to
accounts.all(options, callback);
Get an account the user has access to
The following arguments are required:
- account_id: Identifier of the account
accounts.get("b3ebe711-755e-4a91-b8d2-0cc028827bcf", options, callback);
Update an account the user has access to
The following arguments are required:
- account_id: Identifier of the account
accounts.update("b3ebe711-755e-4a91-b8d2-0cc028827bcf", options, callback);
People who operate or interacted with the account
var people = client.people();
List all people in the account the user has access to
The following arguments are required:
- account_id: Identifier of the account
people.all("b3ebe711-755e-4a91-b8d2-0cc028827bcf", options, callback);
Conversations in an account
var conversations = client.conversations();
List all conversations in an account the user has access to
The following arguments are required:
- account_id: Identifier of the account
conversations.all("b3ebe711-755e-4a91-b8d2-0cc028827bcf", "false", options, callback);
Create an empty conversation in account the user has access to
The following arguments are required:
- account_id: Identifier of the account
conversations.create("b3ebe711-755e-4a91-b8d2-0cc028827bcf", options, callback);
Get a conversation the user has access to
The following arguments are required:
- conversation_id: Identifier of the conversation
conversations.get("10ce24de-23f6-433f-9a71-255cffffa96f", options, callback);
Messages in a conversation
var messages = client.messages();
Get a message the user has access to
The following arguments are required:
- message_id: Identifier of the message
messages.get("33314e4e-baf5-4b33-be72-112ed86701fd", options, callback);
Here is a list of Contributors
MIT
Report here.
Pavan Kumar Sunkara ([email protected])