@foxy.io/sdk
Version:
Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.
33 lines (32 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNextTransactionDateConstraints = void 0;
const getNextTransactionDateConstraints_js_1 = require("../backend/getNextTransactionDateConstraints.js");
/**
* Finds which next transaction date modification rules are applicable to
* the given subscription and merges them together.
*
* @param data Subscription to generate constraints for.
* @param rules Next date modification config from the customer portal settings.
*
* @returns
* Returns true if all modifications are allowed, false if next date can't
* be changed by the customer, object with constraints in any other case.
*/
function getNextTransactionDateConstraints(data, rules) {
let backendRules;
if (typeof rules === 'boolean') {
backendRules = rules;
}
else {
backendRules = rules.map(rule => ({
allowedDays: rule.allowed_days,
disallowedDates: rule.disallowed_dates,
jsonataQuery: rule.jsonata_query,
max: rule.max,
min: rule.min,
}));
}
return getNextTransactionDateConstraints_js_1.getNextTransactionDateConstraints(data, backendRules);
}
exports.getNextTransactionDateConstraints = getNextTransactionDateConstraints;