rendr-helpers
Version:
helper functions to support rendr api related developement
57 lines (56 loc) • 1.91 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestDelivery = exports.getStore = void 0;
require("isomorphic-fetch");
var getQuote = function (apiUrl, token, tenantId, payload, date) {
var body = JSON.stringify(__assign(__assign({}, payload), { ready_for_pickup_at: date }));
return fetch(apiUrl + "/" + tenantId + "/deliveries/quote", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: "Bearer " + token,
},
body: body,
}).then(function (res) {
// console.log('quote response:', res.json);
return res.json();
});
};
var getStore = function (apiUrl, token, storeId) {
return fetch(apiUrl + "/" + storeId, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: "Bearer " + token,
},
}).then(function (res) { return res.json(); });
};
exports.getStore = getStore;
var requestDelivery = function (apiUrl, token, tenantId, payload) {
var body = JSON.stringify(payload);
return fetch(apiUrl + "/" + tenantId + "/deliveries", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: "Bearer " + token,
},
body: body,
})
.then(function (res) { return res.json(); })
.then(function (res) {
return res;
});
};
exports.requestDelivery = requestDelivery;
exports.default = getQuote;