UNPKG

@arc-publishing/sdk-sales

Version:
37 lines 1.75 kB
import { __awaiter, __generator } from "tslib"; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { isSubscriptionIDResponse } from './subscription'; import Sales from './sales'; import { logPrefix } from './constants'; export default function stopSharing(id) { return __awaiter(this, void 0, void 0, function () { var isLoggedIn; 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 [2, fetch("".concat(Sales.apiOrigin, "/sales/public/v1/subscription/").concat(id, "/stopshare"), { method: 'PUT', headers: { Authorization: "Bearer ".concat(Sales._Identity.userIdentity.accessToken) } }) .then(JSONResponseHandler) .then(function (json) { if (isSubscriptionIDResponse(json)) { Sales.sharedSubscriptions = Sales.sharedSubscriptions.filter(function (s) { return s.subscriptionID !== json.subscriptionID; }); return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=stopSharing.js.map