UNPKG

@arc-publishing/sdk-sales

Version:
32 lines 1.3 kB
import { __awaiter, __generator } from "tslib"; import addItemsToCart from '@arc-publishing/sdk-subs-core/lib/api/sales/addItemsToCart'; import { headers } from './constants'; import { getOptions } from './utils'; import Sales from './sales'; import { isCart } from './order'; export default function addItemToCart(items, billingAddress) { return __awaiter(this, void 0, void 0, function () { var options; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, getOptions({ method: 'POST', headers: headers, body: JSON.stringify({ items: items, billingAddress: billingAddress }) })]; case 1: options = _a.sent(); return [2, addItemsToCart(Sales.apiOrigin, options).then(function (json) { if (isCart(json)) { Sales.cart = json; return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=addItemToCart.js.map