UNPKG

@arc-publishing/sdk-sales

Version:
37 lines 1.68 kB
import { __awaiter, __generator } from "tslib"; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { headers, logPrefix } from './constants'; import { getOptions } from './utils'; import { isOrderResponse } from './order'; import Sales from './sales'; import { updateOrder } from './utils'; export default function getOrderDetails(orderNumber) { return __awaiter(this, void 0, void 0, function () { var isLoggedIn, options; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, Sales._Identity.isLoggedIn()]; case 1: isLoggedIn = _a.sent(); if (!isLoggedIn) { throw new Error("".concat(logPrefix, " Missing or invalid jwt")); } return [4, getOptions({ method: 'GET', headers: headers, cache: 'no-cache' })]; case 2: options = _a.sent(); return [2, fetch("".concat(Sales.apiOrigin, "/sales/public/v1/order/detail/").concat(orderNumber), options) .then(JSONResponseHandler) .then(function (json) { if (isOrderResponse(json)) { Sales.orders = updateOrder(Sales.orders, json); return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=getOrderDetails.js.map