Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "customer/index"

Index

Functions

getAllowedFrequencies

  • getAllowedFrequencies(opts: Options): Generator<string, void, void>
  • Returns allowed frequencies for given subscription and customer portal settings.

    Parameters

    • opts: Options

      Subscription and settings.

    Returns Generator<string, void, void>

    Array of allowed frequencies.

getNextTransactionDateConstraints

  • getNextTransactionDateConstraints(data: Data, rules: Rules): Constraints | boolean
  • Finds which next transaction date modification rules are applicable to the given subscription and merges them together.

    Parameters

    • data: Data

      Subscription to generate constraints for.

    • rules: Rules

      Next date modification config from the customer portal settings.

    Returns Constraints | boolean

    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.

getTimeFromFrequency

  • getTimeFromFrequency(frequency: string): number
  • Gives a rough estimate for a number of milliseconds in the given frequency.

    IMPORTANT: this function SHOULD NOT be used to calculate precise dates as it doesn't account for leap years, months of variable length, etc. It works best for broad estimates and comparing frequencies.

    throws

    InvalidFrequencyError when provided with unsupported frequency.

    Parameters

    • frequency: string

      Frequency as positive integer + units (y, m, w, d for years, months, weeks and days respectively). You can use .5m for twice a month. Example: 1m (1 month), 4y (4 years).

    Returns number

    Estimated number of milliseconds in the given frequency.

isNextTransactionDate

  • isNextTransactionDate(opts: Options): boolean
  • Checks if given date (YYYY-MM-DD) can be used as the next transaction date for given subscription.

    Parameters

    • opts: Options

      Subscription, customer portal settings and value.

    Returns boolean

    True if given date can be used as next transaction date.

Generated using TypeDoc