@cfxlabsinc/b2b-services
    Preparing search index...

    Rules that are configured per customer to trigger rewards on certain events

    Hierarchy (View Summary)

    Index
    db: B2bDatabase
    rewardEventNamesCache: ServiceCache<string[]>
    instance: (...args: []) => RewardEventConfigService = ...

    The process default: built from each dependency's own instance().

    • Match event and event data to the rules defined for the given customer

      If multiple rules match, the first one is returned

      Parameters

      • __namedParameters: { customerId: string; data: object; event: string }
        • customerId: string
        • data: object

          Data associated with the event, compared against rule matchers

        • event: string

      Returns Promise<RewardAmount | null>

      Reward amount that this event qualifies for. null if no active rules match.

    • Parameters

      • __namedParameters: {
            customerId: string;
            events?: string[];
            page?: number;
            pageSize?: number;
            statuses?: ("ACTIVE" | "DISABLED")[];
        }

      Returns Promise<
          {
              ok: true;
              value: { hasNext: boolean; items: RewardEventConfig[]; total: number };
          },
      >

    • Creates or updates the reward event config for the given customer + event (INSERT ... ON CONFLICT DO UPDATE, keyed on the (customer, event) unique index). In case of update, rules replace the previous values (rather than merge).

      Parameters

      • __namedParameters: Omit<
            RewardEventConfig,
            "createdAt"
            | "updatedAt"
            | "eventDescription"
            | "statusDescription",
        > & { customerId: string }

      Returns Promise<
          | { ok: true; value: RewardEventConfig }
          | { error: ServiceError; ok: false },
      >