dispatch-node-sdk
Advanced tools
Comparing version 1.8.1 to 1.8.2
@@ -22,3 +22,5 @@ 'use strict'; | ||
var accountId = offerData.accountId, | ||
data = offerData.data; | ||
data = offerData.data, | ||
_offerData$suggestedT = offerData.suggestedTimes, | ||
suggestedTimes = _offerData$suggestedT === undefined ? {} : _offerData$suggestedT; | ||
@@ -29,5 +31,16 @@ var headers = _extends({}, options.headers, { | ||
options.headers = headers; | ||
return client.doAuthenticatedRequest('POST', endpoints.BOOKING, data, options); | ||
return client.doAuthenticatedRequest('POST', endpoints.BOOKING, data, options).then(function (response) { | ||
// If suggested times, fire the seperate call to add them to the job offer | ||
if (suggestedTimes.suggested_times.length > 0) { | ||
var id = response.job_offer.id; | ||
suggestedTimes.job_offer_id = id; | ||
client.doAuthenticatedRequest('POST', endpoints.APPOINTMENTS + '/next/suggested_times', suggestedTimes, options); // eslint-disable-line prefer-template | ||
} | ||
return response.job_offer; | ||
}); | ||
} | ||
}; | ||
} |
@@ -6,3 +6,3 @@ import * as endpoints from './endpoints'; | ||
bookNewOffer: (offerData, options = {}) => { | ||
const { accountId, data } = offerData; | ||
const { accountId, data, suggestedTimes = {} } = offerData; | ||
const headers = { | ||
@@ -13,5 +13,15 @@ ...options.headers, | ||
options.headers = headers; | ||
return client.doAuthenticatedRequest('POST', endpoints.BOOKING, data, options); | ||
return client.doAuthenticatedRequest('POST', endpoints.BOOKING, data, options).then((response) => { | ||
// If suggested times, fire the seperate call to add them to the job offer | ||
if (suggestedTimes.suggested_times.length > 0) { | ||
const { id } = response.job_offer; | ||
suggestedTimes.job_offer_id = id; | ||
client.doAuthenticatedRequest('POST', endpoints.APPOINTMENTS + '/next/suggested_times', suggestedTimes, options); // eslint-disable-line prefer-template | ||
} | ||
return response.job_offer; | ||
}); | ||
}, | ||
}; | ||
} |
{ | ||
"name": "dispatch-node-sdk", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"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
272360
6821