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

    Client for Girasol's B2B card-issuing API.

    Every Girasol payload arrives inside an envelope — { statusCode, error, data } — so the useful body is response.data.data: openapi-fetch's data (the parsed 2xx body), then the envelope's own data. succeeded checks both the HTTP status and the envelope's error flag before anything reads through it.

    A get returns null for a 404; every other method returns a Result (GIRASOL_ERROR, or <THING>_NOT_FOUND for a 404) and a fault throws. README.md covers regenerating girasol.d.ts and what to distrust in it.

    Index
    instance: (...args: []) => GirasolClient = ...

    The process client, reading the girasol namespace at each call.

    • Activates a physical card. This method calls Girasol's PATCH /v1/cards/activate-card endpoint. CVC_MISMATCH when Girasol names the CVV wrong, CARD_NOT_FOUND for a 404.

      Every outcome is built from status codes alone, never Girasol's text, which could echo the CVV or PIN back.

      Parameters

      • input: { cardId: string; cvv: string; lastFour: string; pin: string }
        • cardId: string

          Format: uuid

        • cvv: string
        • lastFour: string
        • pin: string

      Returns Promise<
          | { ok: true; value: { cardStatus: string } }
          | { error: GirasolActivateCardError; ok: false },
      >

    • Permanently blocks a card by its card ID. This method calls Girasol's PATCH /v1/cards/{cardId}/block endpoint and returns the updated card info. CARD_NOT_FOUND when Girasol has no such card.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | { error: GirasolCardError; ok: false }
          | {
              ok: true;
              value: { cardId: string; cardStatus: string; message: string };
          },
      >

    • Performs a cash-in operation to transfer funds from the CFX Master Account to a customer card account. This method calls Girasol's POST /v1/accounts/cash-in endpoint and returns the transaction details. ACCOUNT_NOT_FOUND when Girasol has no such account.

      Parameters

      • input: CashInGirasolAccountRequest

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | {
              ok: true;
              value: {
                  createdAt: string;
                  currency: string;
                  description: string;
                  MasterAccountBalance: number;
                  transactionId: number;
                  userBalance: number;
              };
          },
      >

    • Performs a cash-out operation to transfer funds from a customer card account to the CFX Master Account. This method calls Girasol's POST /v1/accounts/cash-out endpoint and returns the transaction details. ACCOUNT_NOT_FOUND when Girasol has no such account.

      Parameters

      • input: CashOutGirasolAccountRequest

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | {
              ok: true;
              value: {
                  createdAt: string;
                  currency: string;
                  description: string;
                  MasterAccountBalance: number;
                  transactionId: number;
                  userBalance: number;
              };
          },
      >

    • Creates a new company user account.

      This method calls Girasol's POST /v1/accounts/create-company-user endpoint and returns the created company account details. EMAIL_ALREADY_EXISTS when Girasol already holds an account for the email, and COMPANY_ACCOUNT_EXISTS for any other 409.

      Parameters

      • input: {
            companyAddress: string;
            companyEmail: string;
            companyName: string;
            companyPhone: string;
            incorporationCountryCode: string;
            legalRepresentativeCountryCode: string;
            legalRepresentativeName: string;
            legalRepresentativePassport?: string;
            taxId: string;
        }
        • companyAddress: string

          Full registered address of the company.

        • companyEmail: string

          Format: email

          The company's official email address.

        • companyName: string

          The registered legal name of the company.

        • companyPhone: string

          The company's official phone number including country code.

        • incorporationCountryCode: string

          ISO 3166-1 alpha-3 country code where the company was incorporated. For more info go to country codes

          CUW
          
        • legalRepresentativeCountryCode: string

          ISO 3166-1 alpha-3 country code of the legal representative's nationality. For more info go to country codes

          CUW
          
        • legalRepresentativeName: string

          Full name of the legal representative of the company.

        • OptionallegalRepresentativePassport?: string

          Passport number of the legal representative.

        • taxId: string

          The company's identification number.

      Returns Promise<
          | { ok: true; value: { accountNumber: number; email: string } }
          | { error: GirasolCreateCompanyAccountError; ok: false },
      >

    • Creates a new physical card associated with an account.

      This method calls Girasol's POST /v1/cards/create-card endpoint and returns the created card details. ACCOUNT_NOT_FOUND when Girasol has no such account.

      Parameters

      • input: CreateGirasolPhysicalCardRequest

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | {
              ok: true;
              value: {
                  cardId: string;
                  cardStatus: string;
                  firstName: string;
                  lastName: string;
                  message: string;
                  type: number;
              };
          },
      >

    • Creates a new virtual card associated with an account.

      This method calls Girasol's POST /v1/cards/create-virtual-card endpoint and returns the created card details. ACCOUNT_NOT_FOUND when Girasol has no such account.

      Parameters

      • input: CreateGirasolVirtualCardRequest

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | {
              ok: true;
              value: {
                  cardId: string;
                  cardStatus: string;
                  expirationMonth: string;
                  expirationYear: string;
                  firstName: string;
                  lastDigits: string;
                  lastName: string;
                  message: string;
                  type: number;
              };
          },
      >

    • Freezes an account by changing its status to inactive (status: 2).

      This method calls Girasol's PATCH /v1/accounts/change-account-status endpoint and returns the updated account status information. Calling this 'freeze' purely to align with the terminology used for cards.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | { ok: true; value: GirasolAccountStatusChange },
      >

    • Freezes a card by its card ID.

      This method calls Girasol's PATCH /v1/cards/{cardId}/freeze endpoint and returns the updated card info. CARD_NOT_FOUND when Girasol has no such card.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | { ok: true; value: GirasolCardStatusChange }
          | { error: GirasolCardError; ok: false },
      >

    • Retrieves account information by account ID.

      This method calls Girasol's GET /v1/accounts/customer-info/{numberAccount} endpoint and returns the account details, or null when Girasol has no such account.

      Parameters

      • __namedParameters: { accountNumber: string }

      Returns Promise<GirasolAccount | null>

    • Retrieves card information by card ID.

      This method calls Girasol's GET /v1/cards/info-by-card-id/{cardId} endpoint and returns the card details, or null when Girasol has no such card.

      Parameters

      • __namedParameters: { cardId: string }

      Returns Promise<
          | {
              contactNumber: string;
              createdAt: string;
              id: string;
              lastDigits: string;
              nameForPrint: string;
              status: number;
          }
          | null,
      >

    • PAN, CVV, name and expiry via card-token then card-token-internal. Nothing here logs the result, and no error carries it. null when Girasol has no such card.

      Parameters

      • __namedParameters: { cardId: string }

      Returns Promise<GirasolCardDetails | null>

    • Retrieves cards by account ID.

      This method calls Girasol's GET /v1/cards/info-by-account/{accountNumber} endpoint and returns the card details. ACCOUNT_NOT_FOUND when Girasol has no such account.

      Parameters

      • __namedParameters: { accountNumber: string }

      Returns Promise<
          | {
              ok: true;
              value: {
                  contactNumber: string;
                  createdAt: string;
                  id: string;
                  lastDigits: string;
                  nameForPrint: string;
                  status: number;
              }[];
          }
          | { error: GirasolAccountError; ok: false },
      >

    • One page of a card's ledger at Girasol, newest first: purchases (type 2) and the reversals and refunds that credit them back (type 1). This method calls Girasol's GET /v1/accounts/card-transactions/{cardId}. CARD_NOT_FOUND when Girasol has no such card.

      Parameters

      • __namedParameters: { cardId: string; limit: number; page: number }

      Returns Promise<
          | { error: GirasolCardError; ok: false }
          | {
              ok: true;
              value: {
                  amount: number;
                  category: unknown;
                  createdAt: string;
                  currency: unknown;
                  description: string;
                  id: number;
                  merchant: string;
                  transactionCurrency: unknown;
                  transactionId: string;
                  type: number;
              }[];
          },
      >

    • Retrieves clearing information for a specific date. This method calls Girasol's GET /v1/clearing?date={date} endpoint and returns the clearing details.

      Parameters

      • __namedParameters: { date: string }

      Returns Promise<
          | { ok: true; value: GirasolClearingLine[] }
          | { error: GirasolError; ok: false },
      >

    • Unfreezes an account by changing its status to active (status: 1).

      This method calls Girasol's PATCH /v1/accounts/change-account-status endpoint and returns the updated account status information. Calling this 'unfreeze' purely to align with the terminology used for cards.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | { error: GirasolAccountError; ok: false }
          | { ok: true; value: GirasolAccountStatusChange },
      >

    • Unfreezes a card by its card ID.

      This method calls Girasol's PATCH /v1/cards/{cardId}/unfreeze endpoint and returns the updated card info. The status will change from "FREEZED" to "ACTIVE". CARD_NOT_FOUND when Girasol has no such card.

      Parameters

      • __namedParameters: { id: string }

      Returns Promise<
          | { ok: true; value: GirasolCardStatusChange }
          | { error: GirasolCardError; ok: false },
      >