dispatch-node-sdk
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -51,3 +51,3 @@ 'use strict'; | ||
* @param {Object} config The new config | ||
* @param {Boolean} [override] If true, will set the entity's config to whatever you pass. If | ||
* @param {Boolean} [overwrite] If true, will set the entity's config to whatever you pass. If | ||
* false, will merge whatever you pass onto the existing config. | ||
@@ -60,9 +60,74 @@ * @return {Promise} | ||
value: function setForEntity(entityType, entityID, config) { | ||
var override = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
var overwrite = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3]; | ||
return this.client.doAuthenticatedRequest('POST', '/config/' + entityType + '/' + entityID, { | ||
config: config, | ||
override: override | ||
overwrite: overwrite | ||
}); | ||
} | ||
/** | ||
* Get the default configuration | ||
* | ||
* @return {Promise} | ||
*/ | ||
}, { | ||
key: 'getDefault', | ||
value: function getDefault() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/default'); | ||
} | ||
/** | ||
* Set the default app or notifications configuration | ||
* | ||
* @param {String} prefix "app" or "notifications" | ||
* @param {Object} config The new default config | ||
* @return {Promise} | ||
*/ | ||
}, { | ||
key: 'setDefaultForPrefix', | ||
value: function setDefaultForPrefix(prefix, config) { | ||
return this.client.doAuthenticatedRequest('POST', '/config/default', { | ||
config: config, | ||
prefix: prefix | ||
}); | ||
} | ||
/** | ||
* Gets the current full configuration schema | ||
* | ||
* @return {Promise} | ||
*/ | ||
}, { | ||
key: 'schema', | ||
value: function schema() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/schema'); | ||
} | ||
/** | ||
* Gets the current full notifications events list | ||
* | ||
* @return {Promise} | ||
*/ | ||
}, { | ||
key: 'eventsList', | ||
value: function eventsList() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/events_list'); | ||
} | ||
/** | ||
* Gets a report of all the levels at which each configuration setting is defined | ||
* @param {String} type One of 'app', 'email', 'sms', 'push', or 'webhook' | ||
* @return {Promise} | ||
*/ | ||
}, { | ||
key: 'report', | ||
value: function report(type) { | ||
return this.client.doAuthenticatedRequest('GET', '/config/report/' + type); | ||
} | ||
}]); | ||
@@ -69,0 +134,0 @@ |
@@ -123,3 +123,3 @@ 'use strict'; | ||
function Dispatch(clientID, clientSecret) { | ||
var host = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'https://api.dispatch.me'; | ||
var host = arguments.length <= 2 || arguments[2] === undefined ? 'https://api.dispatch.me' : arguments[2]; | ||
@@ -487,3 +487,3 @@ _classCallCheck(this, Dispatch); | ||
var refreshToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; | ||
var refreshToken = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; | ||
@@ -511,4 +511,4 @@ return this.getNoAuthClient().post('/oauth/token', { | ||
value: function getCollection(endpoint) { | ||
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var filter = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; | ||
var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -541,3 +541,3 @@ var fullPath = endpoint; | ||
value: function getCollectionWithMeta(endpoint) { | ||
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
var filter = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; | ||
@@ -569,3 +569,3 @@ return this.getCollection(endpoint, filter, { raw: true }).then(function (response) { | ||
value: function appendAnalyticsHeaders() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -603,4 +603,4 @@ var analytics = Object.assign({}, this.session, options.analytics); | ||
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var body = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
@@ -663,3 +663,3 @@ var req = new _request2.default(method, endpoint, body, this.appendAnalyticsHeaders(options)); | ||
value: function uploadFile(file, name) { | ||
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'square_photo'; | ||
var type = arguments.length <= 2 || arguments[2] === undefined ? 'square_photo' : arguments[2]; | ||
var options = arguments[3]; | ||
@@ -686,3 +686,3 @@ | ||
value: function setSession() { | ||
var sessionVars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var sessionVars = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -706,6 +706,6 @@ this.session = sessionVars; | ||
var organizationID = _ref.organizationID, | ||
query = _ref.query, | ||
filter = _ref.filter, | ||
maxResultsPerModel = _ref.maxResultsPerModel; | ||
var organizationID = _ref.organizationID; | ||
var query = _ref.query; | ||
var filter = _ref.filter; | ||
var maxResultsPerModel = _ref.maxResultsPerModel; | ||
@@ -812,3 +812,3 @@ var customers = void 0; | ||
var appointmentInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var appointmentInfo = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
@@ -815,0 +815,0 @@ var returnData = { |
@@ -18,3 +18,3 @@ 'use strict'; | ||
sendNotification: function sendNotification(appointmentProperties) { | ||
var headerOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var headerOptions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -21,0 +21,0 @@ return client.doAuthenticatedRequest('PATCH', endpoints.APPOINTMENTS + '/' + id + '/notify', appointmentProperties, headerOptions); |
@@ -36,4 +36,4 @@ 'use strict'; | ||
value: function get() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var query = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -45,3 +45,3 @@ return this.client.getCollection(this.endpoint, query, opts); | ||
value: function getWithMeta() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var query = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -58,3 +58,3 @@ return this.client.getCollectionWithMeta(this.endpoint, query); | ||
value: function create(data) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -76,3 +76,3 @@ return this.client.doAuthenticatedRequest('POST', this.endpoint, data, options).then(function (response) { | ||
value: function update(id, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -102,4 +102,4 @@ return this.client.doAuthenticatedRequest('PATCH', this.getSingleEndpoint(id), data, options).then(function (response) { | ||
return this.getWithMeta(_extends({}, query, { limit: 0 })).then(function (_ref) { | ||
var _ref$meta = _ref.meta, | ||
meta = _ref$meta === undefined ? {} : _ref$meta; | ||
var _ref$meta = _ref.meta; | ||
var meta = _ref$meta === undefined ? {} : _ref$meta; | ||
@@ -106,0 +106,0 @@ return meta.total; |
@@ -13,4 +13,4 @@ 'use strict'; | ||
getConversation: function getConversation(_ref) { | ||
var organizationID = _ref.organizationID, | ||
customerUserID = _ref.customerUserID; | ||
var organizationID = _ref.organizationID; | ||
var customerUserID = _ref.customerUserID; | ||
@@ -17,0 +17,0 @@ if (!organizationID || !customerUserID) { |
@@ -20,5 +20,5 @@ 'use strict'; | ||
pay: function pay(_ref) { | ||
var amount = _ref.amount, | ||
cardToken = _ref.cardToken, | ||
paymentMethod = _ref.paymentMethod; | ||
var amount = _ref.amount; | ||
var cardToken = _ref.cardToken; | ||
var paymentMethod = _ref.paymentMethod; | ||
@@ -25,0 +25,0 @@ if (cardToken) { |
@@ -42,5 +42,5 @@ 'use strict'; | ||
return client.entities.jobs.getOne(id).then(function (_ref) { | ||
var organization_id = _ref.organization_id, | ||
_ref$customer = _ref.customer, | ||
customer = _ref$customer === undefined ? {} : _ref$customer; | ||
var organization_id = _ref.organization_id; | ||
var _ref$customer = _ref.customer; | ||
var customer = _ref$customer === undefined ? {} : _ref$customer; | ||
@@ -68,3 +68,3 @@ return client.entities.billingDocuments.create({ | ||
function actOnOffer(client, id, action, statusMessage, body) { | ||
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {}; | ||
var options = arguments.length <= 5 || arguments[5] === undefined ? {} : arguments[5]; | ||
@@ -184,3 +184,3 @@ return client.entities.jobs.getOne(id).then(function (_ref2) { | ||
createAppointment: function createAppointment() { | ||
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var data = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments[1]; | ||
@@ -196,3 +196,3 @@ | ||
getAppointments: function getAppointments() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var query = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -227,3 +227,3 @@ if (query.filter) { | ||
getSurveys: function getSurveys() { | ||
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var query = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -244,3 +244,3 @@ var DEFAULT_QUERY = { | ||
update: function update(jobProperties) { | ||
var headerOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var headerOptions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -247,0 +247,0 @@ return client.doAuthenticatedRequest('PATCH', endpoints.JOBS + '/' + id, jobProperties, headerOptions).then(function (response) { |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
@@ -10,0 +10,0 @@ exports.default = organizationMethods; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
@@ -10,0 +10,0 @@ exports.default = userMethods; |
@@ -30,7 +30,7 @@ 'use strict'; | ||
function getAuthHeaders(_ref) { | ||
var path = _ref.path, | ||
body = _ref.body, | ||
userID = _ref.userID, | ||
userType = _ref.userType, | ||
secret = _ref.secret; | ||
var path = _ref.path; | ||
var body = _ref.body; | ||
var userID = _ref.userID; | ||
var userType = _ref.userType; | ||
var secret = _ref.secret; | ||
@@ -37,0 +37,0 @@ // Date must be formatted like this: |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
@@ -10,0 +10,0 @@ exports.stringify = stringify; |
@@ -88,3 +88,3 @@ 'use strict'; | ||
value: function get(endpoint) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -96,3 +96,3 @@ return this.doRequest('GET', endpoint, null, options); | ||
value: function post(endpoint, body) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -104,3 +104,3 @@ return this.doRequest('POST', endpoint, body, options); | ||
value: function put(endpoint, body) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -112,3 +112,3 @@ return this.doRequest('PUT', endpoint, body, options); | ||
value: function patch(endpoint, body) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -120,3 +120,3 @@ return this.doRequest('PATCH', endpoint, body, options); | ||
value: function _delete(endpoint) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -128,4 +128,4 @@ return this.doRequest('DELETE', endpoint, null, options); | ||
value: function doRequest(method, endpoint) { | ||
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var body = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
@@ -132,0 +132,0 @@ var url = this.host + endpoint; |
@@ -13,4 +13,4 @@ "use strict"; | ||
function Request(method, endpoint) { | ||
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var body = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; | ||
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
@@ -17,0 +17,0 @@ _classCallCheck(this, Request); |
@@ -35,12 +35,63 @@ import { stringify } from './queryString'; | ||
* @param {Object} config The new config | ||
* @param {Boolean} [override] If true, will set the entity's config to whatever you pass. If | ||
* @param {Boolean} [overwrite] If true, will set the entity's config to whatever you pass. If | ||
* false, will merge whatever you pass onto the existing config. | ||
* @return {Promise} | ||
*/ | ||
setForEntity(entityType, entityID, config, override = false) { | ||
setForEntity(entityType, entityID, config, overwrite = false) { | ||
return this.client.doAuthenticatedRequest('POST', `/config/${entityType}/${entityID}`, { | ||
config, | ||
override, | ||
overwrite, | ||
}); | ||
} | ||
/** | ||
* Get the default configuration | ||
* | ||
* @return {Promise} | ||
*/ | ||
getDefault() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/default'); | ||
} | ||
/** | ||
* Set the default app or notifications configuration | ||
* | ||
* @param {String} prefix "app" or "notifications" | ||
* @param {Object} config The new default config | ||
* @return {Promise} | ||
*/ | ||
setDefaultForPrefix(prefix, config) { | ||
return this.client.doAuthenticatedRequest('POST', '/config/default', { | ||
config, | ||
prefix, | ||
}); | ||
} | ||
/** | ||
* Gets the current full configuration schema | ||
* | ||
* @return {Promise} | ||
*/ | ||
schema() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/schema'); | ||
} | ||
/** | ||
* Gets the current full notifications events list | ||
* | ||
* @return {Promise} | ||
*/ | ||
eventsList() { | ||
return this.client.doAuthenticatedRequest('GET', '/config/events_list'); | ||
} | ||
/** | ||
* Gets a report of all the levels at which each configuration setting is defined | ||
* @param {String} type One of 'app', 'email', 'sms', 'push', or 'webhook' | ||
* @return {Promise} | ||
*/ | ||
report(type) { | ||
return this.client.doAuthenticatedRequest('GET', `/config/report/${type}`); | ||
} | ||
} |
@@ -37,3 +37,3 @@ import expect from 'expect'; | ||
}, | ||
override: false, | ||
overwrite: false, | ||
}).reply(200, { | ||
@@ -52,2 +52,73 @@ foo: 'bar', | ||
}); | ||
describe('getDefault', () => { | ||
it('should make correct API call', done => { | ||
const req = nock('https://api.dispatch.me').get('/config/default').reply(200, { | ||
foo: 'bar', | ||
}); | ||
client.configuration.getDefault().then(response => { | ||
expect(response).toEqual({ foo: 'bar' }); | ||
expect(req.isDone()).toEqual(true); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
describe('setDefaultForPrefix', () => { | ||
it('should make correct API call', done => { | ||
const req = nock('https://api.dispatch.me').post('/config/default', { | ||
config: { | ||
foo: 'bar', | ||
}, | ||
prefix: 'app', | ||
}).reply(200, { | ||
foo: 'bar', | ||
}); | ||
client.configuration.setDefaultForPrefix('app', { | ||
foo: 'bar', | ||
}).then(response => { | ||
expect(response).toEqual({ foo: 'bar' }); | ||
expect(req.isDone()).toEqual(true); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
describe('schema', () => { | ||
it('should make correct API call', done => { | ||
const req = nock('https://api.dispatch.me').get('/config/schema').reply(200, { | ||
foo: 'bar', | ||
}); | ||
client.configuration.schema().then(response => { | ||
expect(response).toEqual({ foo: 'bar' }); | ||
expect(req.isDone()).toEqual(true); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
describe('eventsList', () => { | ||
it('should make correct API call', done => { | ||
const req = nock('https://api.dispatch.me').get('/config/events_list').reply(200, ['a', 'b']); | ||
client.configuration.eventsList().then(response => { | ||
expect(response).toEqual(['a', 'b']); | ||
expect(req.isDone()).toEqual(true); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
describe('report', () => { | ||
it('should make correct API call', done => { | ||
const req = nock('https://api.dispatch.me').get('/config/report/app').reply(200, { | ||
report: 'bar', | ||
}); | ||
client.configuration.report('app').then(response => { | ||
expect(response).toEqual({ report: 'bar' }); | ||
expect(req.isDone()).toEqual(true); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "dispatch-node-sdk", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "High- and low-level libraries for interacting with the Dispatch API", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
266280
6708