/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CreditCardNetwork, CreditCardNetwork$inboundSchema, CreditCardNetwork$outboundSchema, } from "./creditcardnetwork.js"; export type TestCreditCard = { /** * The credit card's network. */ network: CreditCardNetwork; /** * The Bank Identification Number (BIN). This is typically the first 4 to 6 digits of the account number. */ bin: string; /** * The account number's last four digits. */ last4: string; /** * The token's expiration date. Tokens used past their expiration will be rejected. */ expiration: Date; /** * The Bolt token associated with the credit card. */ token: string; }; /** @internal */ export const TestCreditCard$inboundSchema: z.ZodType< TestCreditCard, z.ZodTypeDef, unknown > = z.object({ network: CreditCardNetwork$inboundSchema, bin: z.string(), last4: z.string(), expiration: z.string().datetime({ offset: true }).transform(v => new Date(v)), token: z.string(), }); /** @internal */ export type TestCreditCard$Outbound = { network: string; bin: string; last4: string; expiration: string; token: string; }; /** @internal */ export const TestCreditCard$outboundSchema: z.ZodType< TestCreditCard$Outbound, z.ZodTypeDef, TestCreditCard > = z.object({ network: CreditCardNetwork$outboundSchema, bin: z.string(), last4: z.string(), expiration: z.date().transform(v => v.toISOString()), token: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TestCreditCard$ { /** @deprecated use `TestCreditCard$inboundSchema` instead. */ export const inboundSchema = TestCreditCard$inboundSchema; /** @deprecated use `TestCreditCard$outboundSchema` instead. */ export const outboundSchema = TestCreditCard$outboundSchema; /** @deprecated use `TestCreditCard$Outbound` instead. */ export type Outbound = TestCreditCard$Outbound; } export function testCreditCardToJSON(testCreditCard: TestCreditCard): string { return JSON.stringify(TestCreditCard$outboundSchema.parse(testCreditCard)); } export function testCreditCardFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TestCreditCard$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TestCreditCard' from JSON`, ); }