UNPKG

@arc-publishing/sdk-sales

Version:
30 lines 1.4 kB
import { __assign, __awaiter, __generator } from "tslib"; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { headers } from './constants'; import Sales from './sales'; export var isCheckSwgSubscriptionTokenResponse = function (response) { return typeof response.exists === 'boolean'; }; export var checkSwgSubscriptionToken = function (_a) { var subscriptionToken = _a.subscriptionToken, _b = _a.findOrCreate, findOrCreate = _b === void 0 ? false : _b; return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_c) { return [2, fetch("".concat(Sales.apiOrigin, "/sales/public/v1/swg/loginexists"), { method: 'POST', headers: headers, body: JSON.stringify(__assign(__assign({}, JSON.parse(subscriptionToken)), { findOrCreate: findOrCreate })) }) .then(JSONResponseHandler) .then(function (response) { if (isCheckSwgSubscriptionTokenResponse(response)) { return response; } else { throw response; } })]; }); }); }; export default checkSwgSubscriptionToken; //# sourceMappingURL=checkSwgSubscriptionToken.js.map