Socket
Socket
Sign inDemoInstall

dispatch-node-sdk

Package Overview
Dependencies
Maintainers
18
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 3.16.2 to 3.16.3

14

dist/lib/dispatch.tests.js

@@ -852,3 +852,6 @@ "use strict";

it('should handle error response from api correctly', function (done) {
var req = (0, _nock["default"])(dispatchUrl).post('/v1/signup', {}, {}).replyWithError(422, {
var req = (0, _nock["default"])(dispatchUrl).post('/v1/signup', {
user: {},
organization: {}
}).reply(422, {
errors: {

@@ -859,9 +862,10 @@ organization: 'Error',

});
client.signUp({}, {}).then(function (response) {
(0, _expect["default"])(response.organization instanceof _errors.UnprocessableEntityError).toEqual(true);
(0, _expect["default"])(response.user).toEqual(null);
client.signUp({}, {})["catch"](function (error) {
(0, _expect["default"])(error instanceof _errors.UnprocessableEntityError).toEqual(true);
(0, _expect["default"])(error.message).toEqual('Validation failed');
(0, _expect["default"])(error.errors.organization).toExist();
req.done();
bearerTokenReq.done();
done();
})["catch"](done());
});
});

@@ -868,0 +872,0 @@ });

@@ -63,3 +63,7 @@ "use strict";

client.setBearerToken(testBearerToken, testRefreshToken);
var scope = (0, _nock["default"])('https://api.dispatch.me').get("".concat(endpoints.ATTACHMENTS, "?filter[id_eq]=123")).reply(200);
var scope = (0, _nock["default"])('https://api.dispatch.me').get("".concat(endpoints.ATTACHMENTS, "?filter[id_eq]=123")).reply(200, {
attachments: [{
id: 123
}]
});
var col = new _Collection["default"](client, endpoints.ATTACHMENTS);

@@ -66,0 +70,0 @@ col.getOne(123);

@@ -25,3 +25,3 @@ "use strict";

if (cardToken) {
if (!paymentMethod && cardToken) {
paymentMethod = 'card';

@@ -28,0 +28,0 @@ }

@@ -202,3 +202,3 @@ "use strict";

}).then(function (appts) {
if (appts.length) {
if (appts === null || appts === void 0 ? void 0 : appts.length) {
return appts[0];

@@ -205,0 +205,0 @@ }

@@ -190,3 +190,8 @@ "use strict";

if (response.status >= 200 && response.status < 300) {
return response.json().then(function (json) {
// this is because we have tests that hit integration URLs
// and they changed some responses to be 204 with empty response
// so .json() would throw parse errors
return response.text().then(function (text) {
if (!text.length) return {};
var json = JSON.parse(text);
if (options.transform) return options.transform(json);

@@ -193,0 +198,0 @@ return json;

@@ -906,16 +906,21 @@ import nock from 'nock';

it('should handle error response from api correctly', (done) => {
const req = nock(dispatchUrl).post('/v1/signup', {}, {}).replyWithError(422, {
errors: {
organization: 'Error',
user: {},
},
});
const req = nock(dispatchUrl)
.post('/v1/signup', { user: {}, organization: {} })
.reply(422, {
errors: {
organization: 'Error',
user: {},
},
});
client.signUp({}, {}).then((response) => {
expect(response.organization instanceof UnprocessableEntityError).toEqual(true);
expect(response.user).toEqual(null);
req.done();
bearerTokenReq.done();
done();
}).catch(done());
client
.signUp({}, {})
.catch((error) => {
expect(error instanceof UnprocessableEntityError).toEqual(true);
expect(error.message).toEqual('Validation failed')
expect(error.errors.organization).toExist()
req.done();
bearerTokenReq.done();
done();
});
});

@@ -922,0 +927,0 @@ });

@@ -52,3 +52,3 @@ import expect from 'expect';

.get(`${endpoints.ATTACHMENTS}?filter[id_eq]=123`)
.reply(200);
.reply(200, { attachments: [{ id: 123 }] });
const col = new Collection(client, endpoints.ATTACHMENTS);

@@ -55,0 +55,0 @@ col.getOne(123);

@@ -14,3 +14,3 @@ import { PAYMENTS } from '../endpoints';

pay: ({ amount, cardToken, paymentMethod }) => {
if (cardToken) {
if (!paymentMethod && cardToken) {
paymentMethod = 'card';

@@ -17,0 +17,0 @@ }

@@ -164,3 +164,3 @@ import isEmpty from 'lodash/isEmpty';

.then((appts) => {
if (appts.length) {
if (appts?.length) {
return appts[0];

@@ -167,0 +167,0 @@ }

@@ -169,6 +169,14 @@ import includes from 'lodash/includes';

if (response.status >= 200 && response.status < 300) {
return response.json().then(json => {
if (options.transform) return options.transform(json);
return json;
});
// this is because we have tests that hit integration URLs
// and they changed some responses to be 204 with empty response
// so .json() would throw parse errors
return response.text()
.then(text => {
if (!text.length) return {};
const json = JSON.parse(text);
if (options.transform) return options.transform(json);
return json;
});
}

@@ -175,0 +183,0 @@

{
"name": "dispatch-node-sdk",
"version": "3.16.2",
"version": "3.16.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