Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dispatch-node-sdk

Package Overview
Dependencies
Maintainers
6
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatch-node-sdk - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

2

dist/lib/configuration.js

@@ -59,3 +59,3 @@ 'use strict';

value: function setForEntity(entityType, entityID, config) {
var override = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
var override = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;

@@ -62,0 +62,0 @@ return this.client.doAuthenticatedRequest('POST', '/config/' + entityType + '/' + entityID, {

@@ -119,3 +119,3 @@ 'use strict';

function Dispatch(clientID, clientSecret) {
var host = arguments.length <= 2 || arguments[2] === undefined ? 'https://api.dispatch.me' : arguments[2];
var host = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'https://api.dispatch.me';

@@ -481,3 +481,3 @@ _classCallCheck(this, Dispatch);

var refreshToken = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
var refreshToken = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

@@ -505,4 +505,4 @@ return this.getNoAuthClient().post('/oauth/token', {

value: function getCollection(endpoint) {
var filter = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -535,3 +535,3 @@ var fullPath = endpoint;

value: function getCollectionWithMeta(endpoint) {
var filter = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

@@ -563,3 +563,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] : {};

@@ -597,4 +597,4 @@ var analytics = Object.assign({}, this.session, options.analytics);

var body = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

@@ -657,3 +657,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 ? 'square_photo' : arguments[2];
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'square_photo';
var options = arguments[3];

@@ -680,3 +680,3 @@

value: function setSession() {
var sessionVars = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var sessionVars = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -700,6 +700,6 @@ this.session = sessionVars;

var organizationID = _ref.organizationID;
var query = _ref.query;
var filter = _ref.filter;
var maxResultsPerModel = _ref.maxResultsPerModel;
var organizationID = _ref.organizationID,
query = _ref.query,
filter = _ref.filter,
maxResultsPerModel = _ref.maxResultsPerModel;

@@ -806,3 +806,3 @@ var customers = void 0;

var appointmentInfo = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var appointmentInfo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -809,0 +809,0 @@ var returnData = {

@@ -13,3 +13,3 @@ 'use strict';

var BRANDS = exports.BRANDS = '/v1/brands';
var CONVERSATION = exports.CONVERSATION = '/v1/conversation';
var CONVERSATIONS = exports.CONVERSATIONS = '/v1/conversations';
var CUSTOMERS = exports.CUSTOMERS = '/v1/customers';

@@ -16,0 +16,0 @@ var JOBS = exports.JOBS = '/v2/jobs';

@@ -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;
var meta = _ref$meta === undefined ? {} : _ref$meta;
var _ref$meta = _ref.meta,
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;
var customerUserID = _ref.customerUserID;
var organizationID = _ref.organizationID,
customerUserID = _ref.customerUserID;

@@ -21,6 +21,6 @@ if (!organizationID || !customerUserID) {

var endpoint = _endpoints.CONVERSATION + '?organization_id=' + organizationID + '&customer_user_id=' + customerUserID;
var endpoint = _endpoints.CONVERSATIONS + '?filter[organization_id]=' + organizationID + '&filter[customer_user_id]=' + customerUserID;
return client.doAuthenticatedRequest('GET', endpoint).then(function (response) {
return response.conversation;
return response.conversations[0];
});

@@ -27,0 +27,0 @@ }

@@ -20,5 +20,5 @@ 'use strict';

pay: function pay(_ref) {
var amount = _ref.amount;
var cardToken = _ref.cardToken;
var paymentMethod = _ref.paymentMethod;
var amount = _ref.amount,
cardToken = _ref.cardToken,
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;
var _ref$customer = _ref.customer;
var customer = _ref$customer === undefined ? {} : _ref$customer;
var organization_id = _ref.organization_id,
_ref$customer = _ref.customer,
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 ? "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 && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -35,2 +35,13 @@ exports.default = organizationMethods;

});
},
getConversations: function getConversations() {
if (!id) {
throw new Error('No organization ID provided');
}
var endpoint = _endpoints.CONVERSATIONS + '?filter[organization_id]=' + id;
return client.doAuthenticatedRequest('GET', endpoint).then(function (response) {
return response.conversations;
});
}

@@ -37,0 +48,0 @@ };

@@ -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 ? "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 && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -10,0 +10,0 @@ exports.default = userMethods;

@@ -30,7 +30,7 @@ 'use strict';

function getAuthHeaders(_ref) {
var path = _ref.path;
var body = _ref.body;
var userID = _ref.userID;
var userType = _ref.userType;
var secret = _ref.secret;
var path = _ref.path,
body = _ref.body,
userID = _ref.userID,
userType = _ref.userType,
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 ? "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 && obj !== Symbol.prototype ? "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 ? null : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
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 ? null : arguments[2];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

@@ -17,0 +17,0 @@ _classCallCheck(this, Request);

@@ -8,3 +8,3 @@ export const ACCOUNTS = '/v1/accounts';

export const BRANDS = '/v1/brands';
export const CONVERSATION = '/v1/conversation';
export const CONVERSATIONS = '/v1/conversations';
export const CUSTOMERS = '/v1/customers';

@@ -11,0 +11,0 @@ export const JOBS = '/v2/jobs';

@@ -1,2 +0,2 @@

import { CONVERSATION } from '../endpoints';
import { CONVERSATIONS } from '../endpoints';

@@ -10,9 +10,9 @@ export default function conversationMethods(client) {

const endpoint = `${CONVERSATION}?organization_id=${organizationID}&customer_user_id=${customerUserID}`;
const endpoint = `${CONVERSATIONS}?filter[organization_id]=${organizationID}&filter[customer_user_id]=${customerUserID}`;
return client
.doAuthenticatedRequest('GET', endpoint)
.then(response => response.conversation);
.then(response => response.conversations[0]);
},
};
}
import expect from 'expect';
import Dispatch from '../dispatch';
import nock from 'nock';
import { CONVERSATION } from '../endpoints';
import { CONVERSATIONS } from '../endpoints';

@@ -20,8 +20,7 @@ const testClientID = '12345';

describe('getConversation', () => {
it('should call the dispatch API endpoint with correct params', (done) => {
it('calls the dispatch API and returns the first conversation', (done) => {
const options = { organizationID: 456, customerUserID: 789 };
const conversationResponse = { ok: true };
const scope = nock('https://api.dispatch.me')
.get(`${CONVERSATION}?organization_id=${options.organizationID}&customer_user_id=${options.customerUserID}`)
.reply(200, { conversation: conversationResponse });
.get(`${CONVERSATIONS}?filter[organization_id]=${options.organizationID}&filter[customer_user_id]=${options.customerUserID}`)
.reply(200, { conversations: [{ foo: 'bar' }, { baz: 'boof' }] });

@@ -31,3 +30,3 @@ client.entities.conversation.getConversation(options)

expect(scope.isDone()).toEqual(true);
expect(response).toEqual(conversationResponse);
expect(response).toEqual({ foo: 'bar' });
done();

@@ -37,3 +36,27 @@ })

});
it('throws an error when incomplete arguments are passed', () => {
const errorMsg = 'Usage: conversation.getConversation({ organization_id: [yourValue], customer_user_id: [yourValue] })';
expect(() => {
client.entities.conversation.getConversation({ customerUserID: 789, organizationID: null });
}).toThrow(errorMsg);
expect(() => {
client.entities.conversation.getConversation({ customerUserID: 789, organizationID: undefined });
}).toThrow(errorMsg);
expect(() => {
client.entities.conversation.getConversation({ customerUserID: null, organizationID: 456 });
}).toThrow(errorMsg);
expect(() => {
client.entities.conversation.getConversation({ customerUserID: undefined, organizationID: 456 });
}).toThrow(errorMsg);
expect(() => {
client.entities.conversation.getConversation({ customerUserID: undefined, organizationID: undefined });
}).toThrow(errorMsg);
});
});
});

@@ -1,2 +0,2 @@

import { CUSTOMERS } from '../endpoints';
import { CONVERSATIONS, CUSTOMERS } from '../endpoints';
import { inWorkHours } from '../workHours';

@@ -26,3 +26,12 @@

},
getConversations: () => {
if (!id) { throw new Error('No organization ID provided'); }
const endpoint = `${CONVERSATIONS}?filter[organization_id]=${id}`;
return client
.doAuthenticatedRequest('GET', endpoint)
.then(response => response.conversations);
},
});
}

@@ -125,2 +125,28 @@ import expect, { spyOn, restoreSpies } from 'expect';

});
describe('getting all conversations', () => {
it('calls the dispatch API and returns all conversations for the organization', (done) => {
const scope = nock('https://api.dispatch.me')
.get(`${endpoints.CONVERSATIONS}?filter[organization_id]=5`)
.reply(200, { conversations: [{ foo: 'bar' }, { baz: 'boof' }] });
client.entities.organization(5).getConversations()
.then((response) => {
expect(scope.isDone()).toEqual(true);
expect(response).toEqual([{ foo: 'bar' }, { baz: 'boof' }]);
done();
})
.catch(done);
});
it('throws an error when no organization ID is passed', () => {
expect(() => {
client.entities.organization(null).getConversations();
}).toThrow('No organization ID provided');
expect(() => {
client.entities.organization(undefined).getConversations();
}).toThrow('No organization ID provided');
});
});
});
{
"name": "dispatch-node-sdk",
"version": "2.1.2",
"version": "2.1.3",
"description": "High- and low-level libraries for interacting with the Dispatch API",

@@ -5,0 +5,0 @@ "main": "dist/lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc