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

    Constructors

    Properties

    dbHelper: DbHelper
    girasolClient: GirasolClient

    Methods

    • Freezes an account by its ID via GirasolClient and updates the local DB status to 'FREEZED'.

      Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns Promise<
          | { ok: true; value: "ACTIVE"
          | "DELETED"
          | "INACTIVE"
          | "UNKNOWN" }
          | { error: ServiceError; ok: false },
      >

    • Parameters

      • __namedParameters: { customerId?: string; id: string }

      Returns Promise<
          {
              ok: true;
              value: | Omit<GirasolCardAccount, "customerRedemptionWalletId"> & {
                  balance: BigNumber | null;
                  customerId: string;
                  customerRedemptionWalletId: string;
                  status: "ACTIVE" | "DELETED" | "INACTIVE" | "UNKNOWN";
              }
              | null;
          },
      >

    • Parameters

      • __namedParameters: {
            customerId?: string;
            customerRedemptionWalletIds?: string[];
            ids?: string[];
            includeStatus?: boolean;
            page?: number;
            pageSize?: number;
        }
        • OptionalcustomerId?: string
        • OptionalcustomerRedemptionWalletIds?: string[]
        • Optionalids?: string[]
        • OptionalincludeStatus?: boolean

          Defaults to false - when true, fetches status from Girasol API

        • Optionalpage?: number

          Defaults to 1

        • OptionalpageSize?: number

          Defaults to 10

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: (
                      Pick<
                          {
                              createdAt: Date;
                              customerId: number;
                              customerRedemptionWalletId: number;
                              data: unknown;
                              externalId: string;
                              girasolAccountNumber: string;
                              id: number;
                              identityId: number
                              | null;
                              organizationId: number | null;
                              updatedAt: Date;
                          },
                          "createdAt"
                          | "updatedAt"
                          | "girasolAccountNumber",
                      > & GirasolCardAccountData & { id: string } & {
                          customerId: string;
                          customerRedemptionWalletId: string;
                          status?: "ACTIVE" | "DELETED" | "INACTIVE" | "UNKNOWN";
                      }
                  )[];
              };
          },
      >

    • Synchronizes balances between a Girasol card account and its associated wallet.

      This method retrieves the current balance from both the Girasol card account and the associated customer redemption wallet, calculates the difference, and optionally adjusts the balances to match.

      Parameters

      • id: { customerId?: string; id: string; simulate?: boolean }

        The external ID of the Girasol card account to synchronize

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

      A Promise that resolves to a Result containing:

      • Success case: Object with synchronization details:

        • girasolBalance: Current balance in the Girasol card account (in USD)
        • walletBalance: Current balance in the associated customer redemption wallet (in MOVEUSD)
        • calculatedDelta: Difference between wallet and Girasol balances (walletBalance - girasolBalance)
        • balanceAdjustedFlag: true if balances were adjusted, false if they were already in sync or in simulation mode
        • transactionId: Girasol transaction ID if an adjustment was made, 0 if simulation mode or no adjustment needed
        • newGirasolBalance: Updated Girasol balance after adjustment, or current balance if no adjustment was made
        • adjustmentAmount: Absolute amount that was adjusted, or 0 if no adjustment was needed
        • adjustmentType: Type of adjustment made: "CASH_IN" (added funds to Girasol), "CASH_OUT" (removed funds from Girasol), or "NONE" if no adjustment was needed
      • Error cases:

        • ACCOUNT_NOT_FOUND: The specified account doesn't exist or balance is unavailable
        • WALLET_NOT_FOUND: The associated customer redemption wallet doesn't exist or balance retrieval failed
        • BALANCE_ADJUSTMENT_ERROR: Failed to perform the balance adjustment via Girasol API
    • Unfreezes an account by its ID via GirasolClient and updates the local DB status from 'FREEZED' to "ACTIVE".

      Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns Promise<
          | { ok: true; value: "ACTIVE"
          | "DELETED"
          | "INACTIVE"
          | "UNKNOWN" }
          | { error: ServiceError; ok: false },
      >