@arc-publishing/sdk-sales
Version:
JS Sales SDK for working with Arc Subs Sales API
42 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = exports.isConfigOptions = void 0;
var tslib_1 = require("tslib");
var APIErrorResponse_1 = require("@arc-publishing/sdk-subs-core/lib/utils/APIErrorResponse");
var JSONResponseHandler_1 = tslib_1.__importDefault(require("@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler"));
var constants_1 = require("./constants");
var sales_1 = tslib_1.__importDefault(require("./sales"));
function isConfigOptions(object) {
return object.checkoutRecaptchaEnabled !== undefined;
}
exports.isConfigOptions = isConfigOptions;
function getConfig() {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (!sales_1.default._configOptions) {
return [2, fetch("".concat(sales_1.default.apiOrigin, "/sales/public/v1/config"), {
method: 'GET',
cache: 'no-cache',
headers: tslib_1.__assign({}, constants_1.headers)
})
.then(JSONResponseHandler_1.default)
.then(function (json) {
if ((0, APIErrorResponse_1.isAPIErrorResponse)(json)) {
throw json;
}
else {
sales_1.default._configOptions = json;
return json;
}
})];
}
else {
return [2, sales_1.default._configOptions];
}
return [2];
});
});
}
exports.getConfig = getConfig;
exports.default = getConfig;
//# sourceMappingURL=getConfig.js.map