Socket
Socket
Sign inDemoInstall

dispatch-node-sdk

Package Overview
Dependencies
Maintainers
4
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.18.0 to 2.18.1

29

dist/lib/dispatch.js

@@ -105,11 +105,2 @@ 'use strict';

var serviceMap = {
config: {
'https://api-dev.dispatch.me': 'https://config-dev.dispatch.me',
'https://api-stg.dispatch.me': 'https://config-staging.dispatch.me',
'https://api-sandbox.dispatch.me': 'https://config-sandbox.dispatch.me',
'https://api.dispatch.me': 'https://config.dispatch.me'
}
};
/**

@@ -125,3 +116,2 @@ * Class Dispatch is the high-level abstracted client for *front-end use only*.

*/
var Dispatch = function () {

@@ -241,4 +231,16 @@ function Dispatch(clientID, clientSecret) {

value: function determineAuxiliaryAPIHost(serviceName) {
var replaceValue = this.host.includes('wfm') ? 'wfm-api' : 'api';
return serviceMap[serviceName] ? serviceMap[serviceName][this.host] : this.host.replace(replaceValue, serviceName);
switch (serviceName) {
case 'config':
case 'files-api':
{
if (this.host.includes('-dev.')) return 'https://' + serviceName + '-dev.dispatch.me';else if (this.host.includes('-stg.') || this.host.includes('-staging.')) return 'https://' + serviceName + '-staging.dispatch.me';else if (this.host.includes('-sandbox.')) return 'https://' + serviceName + '-sandbox.dispatch.me';
return 'https://' + serviceName + '.dispatch.me';
}
default:
{
// XXX This isn't a good way to do this, but leaving it here for backwards compatibility for now
var replaceValue = this.host.includes('wfm') ? 'wfm-api' : 'api';
return this.host.replace(replaceValue, serviceName);
}
}
}

@@ -771,4 +773,3 @@

return this.getAuthClient().get(endpoints.SEARCH + '?organization_id=' + organizationID + '&q=' + query + limitQuery + filterQuery).then(function (response) {
var replaceValue = _this8.authClient.host.includes('wfm') ? 'wfm-api' : 'api';
host = _this8.authClient.host.replace(replaceValue, 'files-api');
host = _this8.determineAuxiliaryAPIHost('files-api');

@@ -775,0 +776,0 @@ // Build customers object for returning.

@@ -25,11 +25,2 @@ import * as endpoints from './endpoints';

const serviceMap = {
config: {
'https://api-dev.dispatch.me': 'https://config-dev.dispatch.me',
'https://api-stg.dispatch.me': 'https://config-staging.dispatch.me',
'https://api-sandbox.dispatch.me': 'https://config-sandbox.dispatch.me',
'https://api.dispatch.me': 'https://config.dispatch.me',
},
};
/**

@@ -142,4 +133,16 @@ * Class Dispatch is the high-level abstracted client for *front-end use only*.

determineAuxiliaryAPIHost(serviceName) {
const replaceValue = this.host.includes('wfm') ? 'wfm-api' : 'api';
return serviceMap[serviceName] ? serviceMap[serviceName][this.host] : this.host.replace(replaceValue, serviceName);
switch (serviceName) {
case 'config':
case 'files-api': {
if (this.host.includes('-dev.')) return `https://${serviceName}-dev.dispatch.me`;
else if (this.host.includes('-stg.') || this.host.includes('-staging.')) return `https://${serviceName}-staging.dispatch.me`;
else if (this.host.includes('-sandbox.')) return `https://${serviceName}-sandbox.dispatch.me`;
return `https://${serviceName}.dispatch.me`;
}
default: {
// XXX This isn't a good way to do this, but leaving it here for backwards compatibility for now
const replaceValue = this.host.includes('wfm') ? 'wfm-api' : 'api';
return this.host.replace(replaceValue, serviceName);
}
}
}

@@ -556,4 +559,3 @@

.then(response => {
const replaceValue = this.authClient.host.includes('wfm') ? 'wfm-api' : 'api';
host = this.authClient.host.replace(replaceValue, 'files-api');
host = this.determineAuxiliaryAPIHost('files-api');

@@ -560,0 +562,0 @@ // Build customers object for returning.

@@ -925,12 +925,70 @@ import nock from 'nock';

describe('determineAuxiliaryAPIHost', () => {
const client = new Dispatch(testClientID, testClientSecret, 'https://api-stg.dispatch.me');
const devClient = new Dispatch(testClientID, testClientSecret, 'https://wfm-api-dev.dispatch.me');
const stagingClient = new Dispatch(testClientID, testClientSecret, 'https://wfm-api-staging.dispatch.me');
const sandboxClient = new Dispatch(testClientID, testClientSecret, 'https://wfm-api-sandbox.dispatch.me');
const prodClient = new Dispatch(testClientID, testClientSecret, 'https://wfm-api.dispatch.me');
it('determines the host of a service using our naming convention', () => {
expect(client.determineAuxiliaryAPIHost('files-api')).toEqual('https://files-api-stg.dispatch.me');
describe('dev', () => {
it('files', () => {
expect(devClient.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api-dev.dispatch.me');
});
it('config', () => {
expect(devClient.determineAuxiliaryAPIHost('config')).toBe('https://config-dev.dispatch.me');
});
it('other', () => {
expect(devClient.determineAuxiliaryAPIHost('other')).toBe('https://other-dev.dispatch.me');
});
});
it('uses a host from the service map if specified', () => {
expect(client.determineAuxiliaryAPIHost('config')).toEqual('https://config-staging.dispatch.me');
describe('staging', () => {
it('files', () => {
expect(stagingClient.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api-staging.dispatch.me');
});
it('config', () => {
expect(stagingClient.determineAuxiliaryAPIHost('config')).toBe('https://config-staging.dispatch.me');
});
it('other', () => {
expect(stagingClient.determineAuxiliaryAPIHost('other')).toBe('https://other-staging.dispatch.me');
});
});
describe('sandbox', () => {
it('files', () => {
expect(sandboxClient.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api-sandbox.dispatch.me');
});
it('config', () => {
expect(sandboxClient.determineAuxiliaryAPIHost('config')).toBe('https://config-sandbox.dispatch.me');
});
it('other', () => {
expect(sandboxClient.determineAuxiliaryAPIHost('other')).toBe('https://other-sandbox.dispatch.me');
});
});
describe('production', () => {
it('files', () => {
expect(prodClient.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api.dispatch.me');
});
it('config', () => {
expect(prodClient.determineAuxiliaryAPIHost('config')).toBe('https://config.dispatch.me');
});
it('other', () => {
expect(prodClient.determineAuxiliaryAPIHost('other')).toBe('https://other.dispatch.me');
});
});
it('admin-api', () => {
let client = new Dispatch(testClientID, testClientSecret, 'https://admin-api.dispatch.me');
expect(client.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api.dispatch.me');
client = new Dispatch(testClientID, testClientSecret, 'https://admin-api-dev.dispatch.me');
expect(client.determineAuxiliaryAPIHost('files-api')).toBe('https://files-api-dev.dispatch.me');
});
});
});
{
"name": "dispatch-node-sdk",
"version": "2.18.0",
"version": "2.18.1",
"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