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

    Customer card writes. Each write to Girasol stores the status Girasol answers, then busts the cache this class reads through.

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<GirasolCardSearchItem>>
    db: B2bDatabase
    girasolClient: GirasolClient
    instance: (...args: []) => GirasolCardService = ...

    The process service: the shared database, Valkey, Girasol, the quote engine and the internal bus.

    • Activates a delivered physical card with the CVV printed on it and a new PIN. Neither value is stored, logged or put in an error.

      Parameters

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

      Returns Promise<
          | {
              ok: true;
              value: | "ACTIVE"
              | "DELETED"
              | "BLOCKED"
              | "REJECTED"
              | "UNKNOWN"
              | "CREATED"
              | "REQUESTED"
              | "EXPIRED"
              | "FROZEN"
              | "DELIVERED";
          }
          | {
              error: | ServiceError<
                  "INVALID_CVV"
                  | "INVALID_PIN"
                  | "CVV_MISMATCH"
                  | "ACTIVATION_REJECTED",
              >
              | ServiceError<"CARD_NOT_FOUND" | "LAST_FOUR_DIGITS_UNAVAILABLE">;
              ok: false;
          },
      >

    • Parameters

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

      Returns Promise<
          | {
              ok: true;
              value: | "ACTIVE"
              | "DELETED"
              | "BLOCKED"
              | "REJECTED"
              | "UNKNOWN"
              | "CREATED"
              | "REQUESTED"
              | "EXPIRED"
              | "FROZEN"
              | "DELIVERED";
          }
          | { error: ServiceError; ok: false },
      >

    • Parameters

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

      Returns Promise<
          | { error: ServiceError; ok: false }
          | {
              ok: true;
              value:
                  | "ACTIVE"
                  | "DELETED"
                  | "BLOCKED"
                  | "REJECTED"
                  | "UNKNOWN"
                  | "CREATED"
                  | "REQUESTED"
                  | "EXPIRED"
                  | "FROZEN"
                  | "DELIVERED";
          },
      >

    • The customer's active Girasol card account.

      Parameters

      • __namedParameters: { customerId: string }

      Returns Promise<
          | {
              ok: true;
              value: {
                  externalId: string;
                  girasolAccountNumber: string;
                  id: number;
                  status: "ACTIVE"
                  | "DELETED"
                  | "INACTIVE"
                  | "UNKNOWN";
              };
          }
          | { error: ServiceError; ok: false },
      >

    • Clear each customer's membership tag and each record tag wherever cached, and always this namespace's collection tag. keys are exact deletes in this instance's key space: the only bust a null client honours.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[];
            keys?: readonly CacheKey[];
            records?: readonly string[];
        }

      Returns Promise<void>

    • Returns a physical card's last four digits, storing them from Girasol when the row has none. Activation needs them, and create may not have had them.

      Parameters

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

      Returns Promise<
          | {
              ok: true;
              value: Pick<
                  {
                      cardholderName: string;
                      createdAt: Date;
                      displayName: string;
                      expiryMonth: string
                      | null;
                      expiryYear: string | null;
                      firstName: string;
                      girasolCardId: string;
                      id: string;
                      lastFourDigits: string | null;
                      lastName: string;
                      maskedCardNumber: string;
                      phone: string;
                      shippingAddress:
                          | {
                              city: string;
                              countryCode: string;
                              line1: string;
                              line2?: string;
                              postalCode: string;
                              region?: string;
                          }
                          | null;
                      status: | "ACTIVE"
                      | "DELETED"
                      | "BLOCKED"
                      | "REJECTED"
                      | "UNKNOWN"
                      | "CREATED"
                      | "REQUESTED"
                      | "EXPIRED"
                      | "FROZEN"
                      | "DELIVERED";
                      statusDescription: string;
                      type: "VIRTUAL"
                      | "PHYSICAL";
                      typeDescription: string;
                      updatedAt: Date;
                  },
                  "girasolCardId",
              > & { lastFourDigits: string };
          }
          | { error: ServiceError; ok: false },
      >

    • Reads the card's PAN, CVV, printed name and expiry from Girasol. The result is never cached, logged or stored.

      Parameters

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

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

    • Tags for a page: the scope its query searched (each customer's membership tag, else the collection tag), so an empty page is bustable too, plus the records it projects and the fields that chose or ordered its rows.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[] | undefined;
            fields?: readonly string[];
            records?: readonly string[];
        }

      Returns string[]

    • Parameters

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

      Returns Promise<
          | { error: ServiceError; ok: false }
          | {
              ok: true;
              value:
                  | "ACTIVE"
                  | "DELETED"
                  | "BLOCKED"
                  | "REJECTED"
                  | "UNKNOWN"
                  | "CREATED"
                  | "REQUESTED"
                  | "EXPIRED"
                  | "FROZEN"
                  | "DELIVERED";
          },
      >

    • The search arguments get reads through. Every default is spelled out, so the same object is also search's cache key for that entry.

      Parameters

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

      Returns { customerId: string; ids: string[]; page: number; pageSize: number }