UNPKG

@foxy.io/sdk

Version:

Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.

29 lines (28 loc) 1.04 kB
import { getNextTransactionDateConstraints as backendUtility } from '../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. */ export 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 backendUtility(data, backendRules); }