freshsales-api
v1.0.1
Published
FreshSales Api for NodeJS
Downloads
9
Maintainers
Readme
nodejs-freshsales
FreshSales api wrapper for the freshsales api. Has Promise handling. See https://www.freshsales.io/api/
var FreshSales = require('freshsales-api')
//Using API-KEY
var authentication = {
api_key: "FRESH SALES API KEY"
};
//Using email and password
var authentication = {
email: "FRESH SALES Email",
password: "FRESH SALES PASSWORD"
};
/**
* Initiate FreshSales Constructor, to setup the API
* authentication - THe authentication object
* domain - Your FreshSales URL : Syntax = https://subdomain.freshsales.io
*
* Throws the following possible errors:
* 1. If domain is missing: "Domain name required for FreshSales API. Syntax: https://domain.freshsales.io"
* 2. If authentication object does not contain API key or UserCredentials - "API Key or UserCredentials not provided"
*/
var freshsales = new FreshSales(domain, authentication);
//Promise style
var options = {
endpoint: 'API Endpoint',
payload: payload
};
var method = "POST|GET|PUT|DELETE"
freshsales.request(method, options).then(function (result) {
...
}).catch(function (err) {
...
});
Installation
NPM package is available for the repository. You can either install it from the NPM package directory or via the git url as:
npm install freshsales-api
[OR]
npm install GIT_REMOTE_URL
Usage
For information on the possible endpoints, refer to the FreshSales Api documentation: https://www.freshsales.io/api
Steps
Initialization
var FreshSales = require('freshsales-api')
API Setup
/**
* Initiate FreshSales Constructor, to setup the API
* authentication - THe authentication object
* domain - Your FreshSales URL : Syntax = https://subdomain.freshsales.io
*
* Throws the following possible errors:
* 1. If domain is missing: "Domain name required for FreshSales API. Syntax: https://domain.freshsales.io"
* 2. If authentication object does not contain API key or UserCredentials - "API Key or UserCredentials not provided"
*/
var freshsales = new FreshSales(domain, authentication);
Authentication Object can be any one of the following Using API-KEY
var authentication = {
api_key: "FRESH SALES API KEY"
};
Using email and password
var authentication = {
email: "FRESH SALES Email",
password: "FRESH SALES PASSWORD"
};
Standard Calls
var options = {
endpoint: 'API Endpoint',
payload: 'Th object containing payload to be sent if a POST or PUT request is made',
query: 'The object containing key-value pair of parameters to be attached to the request url'
};
var method = "POST|GET|PUT|DELETE";
//Response would be a json response at all times
freshsales.request(method, options).then(function (result) {
...
}).catch(function (err) {
...
});
Future Updates
Support for the following will be added over time:
- Callback Support for the available methods
- Support for PathParams as a separate key in the available method
- Helper methods - Convenience methods such as FreshSales.get, FreshSales.put, FreshSales.push, FreshSales.delete
Suggestion and Bugs and Problems and Fixes in the Source Code are welcome.