dispatch-node-sdk
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -62,8 +62,9 @@ 'use strict'; | ||
* @param {String} action The action to perform (accept or reject). | ||
* @param {String} statusMessage The status message (timeslot or reject reason). | ||
* @param {String} body The body of the request to send to the API. | ||
* @param {Object} [options] Options for authenticated request. | ||
* @return {Promise} A Promise with the job offer status and id as the response. | ||
*/ | ||
function actOnOffer(client, id, action, statusMessage, body) { | ||
var options = arguments.length <= 5 || arguments[5] === undefined ? {} : arguments[5]; | ||
function actOnOffer(client, id, action) { | ||
var body = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]; | ||
@@ -102,6 +103,5 @@ return client.entities.jobs.getOne(id).then(function (_ref2) { | ||
if (action === 'reject') { | ||
return client.doAuthenticatedRequest('PATCH', endpoints.JOBS + '/' + id, { | ||
status: 'rejected', | ||
status_message: statusMessage | ||
}, options).then(function () { | ||
return client.doAuthenticatedRequest('PATCH', endpoints.JOBS + '/' + id, _extends({}, body, { | ||
status: 'rejected' | ||
}), options).then(function () { | ||
// Mimic the response of the job offers orchestrator. | ||
@@ -249,6 +249,6 @@ return { status: 'rejected' }; | ||
accept: function accept(timeslot, body, options) { | ||
return actOnOffer(client, id, 'accept', timeslot, body, options); | ||
return actOnOffer(client, id, 'accept', body, options); | ||
}, | ||
reject: function reject(rejectReason, options) { | ||
return actOnOffer(client, id, 'reject', rejectReason, null, options); | ||
return actOnOffer(client, id, 'reject', { status_message: rejectReason }, options); | ||
} | ||
@@ -255,0 +255,0 @@ }; |
@@ -45,7 +45,7 @@ import * as endpoints from '../endpoints'; | ||
* @param {String} action The action to perform (accept or reject). | ||
* @param {String} statusMessage The status message (timeslot or reject reason). | ||
* @param {String} body The body of the request to send to the API. | ||
* @param {Object} [options] Options for authenticated request. | ||
* @return {Promise} A Promise with the job offer status and id as the response. | ||
*/ | ||
function actOnOffer(client, id, action, statusMessage, body, options = {}) { | ||
function actOnOffer(client, id, action, body = {}, options = {}) { | ||
return client.entities.jobs.getOne(id).then(({ job_offer_uuid: uuid }) => { | ||
@@ -82,4 +82,4 @@ // If there is a job offer uuid associated with the job, | ||
return client.doAuthenticatedRequest('PATCH', `${endpoints.JOBS}/${id}`, { | ||
...body, | ||
status: 'rejected', | ||
status_message: statusMessage, | ||
}, options).then(() => { | ||
@@ -205,9 +205,9 @@ // Mimic the response of the job offers orchestrator. | ||
accept(timeslot, body, options) { | ||
return actOnOffer(client, id, 'accept', timeslot, body, options); | ||
return actOnOffer(client, id, 'accept', body, options); | ||
}, | ||
reject(rejectReason, options) { | ||
return actOnOffer(client, id, 'reject', rejectReason, null, options); | ||
return actOnOffer(client, id, 'reject', { status_message: rejectReason }, options); | ||
}, | ||
}); | ||
} |
@@ -445,6 +445,6 @@ import expect from 'expect'; | ||
const offersPostRequest = nock('https://api.dispatch.me') | ||
.post('/offers/test/reject') | ||
.post('/offers/test/reject', { status_message: 'wrong_trade' }) | ||
.reply(200, { status: 'rejected' }); | ||
client.entities.job(123).reject().then(response => { | ||
client.entities.job(123).reject('wrong_trade').then(response => { | ||
expect(jobGetRequest.isDone()).toEqual(true); | ||
@@ -471,6 +471,6 @@ expect(offersPostRequest.isDone()).toEqual(true); | ||
const jobPatchRequest = nock('https://api.dispatch.me') | ||
.patch(`${endpoints.JOBS}/123`, { status: 'rejected' }) | ||
.patch(`${endpoints.JOBS}/123`, { status: 'rejected', status_message: 'wrong_trade' }) | ||
.reply(200, { status: 'rejected' }); | ||
client.entities.job(123).reject().then(response => { | ||
client.entities.job(123).reject('wrong_trade').then(response => { | ||
expect(jobGetRequest.isDone()).toEqual(true); | ||
@@ -477,0 +477,0 @@ expect(jobPatchRequest.isDone()).toEqual(true); |
{ | ||
"name": "dispatch-node-sdk", | ||
"version": "2.8.0", | ||
"version": "2.8.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
270981