/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AddressReference, AddressReference$inboundSchema, AddressReference$Outbound, AddressReference$outboundSchema, } from "./addressreference.js"; import { AddressReferenceInput, AddressReferenceInput$inboundSchema, AddressReferenceInput$Outbound, AddressReferenceInput$outboundSchema, } from "./addressreferenceinput.js"; import { CreditCardNetwork, CreditCardNetwork$inboundSchema, CreditCardNetwork$outboundSchema, } from "./creditcardnetwork.js"; export enum DotTag { CreditCard = "credit_card", } export type PaymentMethodCreditCard = { dotTag: DotTag; id?: string | undefined; billingAddress: AddressReference; /** * The credit card's network. */ network: CreditCardNetwork; /** * The account number's last four digits. */ last4: string; /** * The expiration date, in YYYY-MM format. */ expiration: string; }; export type PaymentMethodCreditCardInput = { dotTag: DotTag; billingAddress: AddressReferenceInput; /** * 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 expiration date, in YYYY-MM format. */ expiration: string; /** * The Bolt token associated with the credit card. */ token: string; }; /** @internal */ export const DotTag$inboundSchema: z.ZodNativeEnum = z .nativeEnum(DotTag); /** @internal */ export const DotTag$outboundSchema: z.ZodNativeEnum = DotTag$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace DotTag$ { /** @deprecated use `DotTag$inboundSchema` instead. */ export const inboundSchema = DotTag$inboundSchema; /** @deprecated use `DotTag$outboundSchema` instead. */ export const outboundSchema = DotTag$outboundSchema; } /** @internal */ export const PaymentMethodCreditCard$inboundSchema: z.ZodType< PaymentMethodCreditCard, z.ZodTypeDef, unknown > = z.object({ ".tag": DotTag$inboundSchema, id: z.string().optional(), billing_address: AddressReference$inboundSchema, network: CreditCardNetwork$inboundSchema, last4: z.string(), expiration: z.string(), }).transform((v) => { return remap$(v, { ".tag": "dotTag", "billing_address": "billingAddress", }); }); /** @internal */ export type PaymentMethodCreditCard$Outbound = { ".tag": string; id?: string | undefined; billing_address: AddressReference$Outbound; network: string; last4: string; expiration: string; }; /** @internal */ export const PaymentMethodCreditCard$outboundSchema: z.ZodType< PaymentMethodCreditCard$Outbound, z.ZodTypeDef, PaymentMethodCreditCard > = z.object({ dotTag: DotTag$outboundSchema, id: z.string().optional(), billingAddress: AddressReference$outboundSchema, network: CreditCardNetwork$outboundSchema, last4: z.string(), expiration: z.string(), }).transform((v) => { return remap$(v, { dotTag: ".tag", billingAddress: "billing_address", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentMethodCreditCard$ { /** @deprecated use `PaymentMethodCreditCard$inboundSchema` instead. */ export const inboundSchema = PaymentMethodCreditCard$inboundSchema; /** @deprecated use `PaymentMethodCreditCard$outboundSchema` instead. */ export const outboundSchema = PaymentMethodCreditCard$outboundSchema; /** @deprecated use `PaymentMethodCreditCard$Outbound` instead. */ export type Outbound = PaymentMethodCreditCard$Outbound; } export function paymentMethodCreditCardToJSON( paymentMethodCreditCard: PaymentMethodCreditCard, ): string { return JSON.stringify( PaymentMethodCreditCard$outboundSchema.parse(paymentMethodCreditCard), ); } export function paymentMethodCreditCardFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentMethodCreditCard$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentMethodCreditCard' from JSON`, ); } /** @internal */ export const PaymentMethodCreditCardInput$inboundSchema: z.ZodType< PaymentMethodCreditCardInput, z.ZodTypeDef, unknown > = z.object({ ".tag": DotTag$inboundSchema, billing_address: AddressReferenceInput$inboundSchema, network: CreditCardNetwork$inboundSchema, bin: z.string(), last4: z.string(), expiration: z.string(), token: z.string(), }).transform((v) => { return remap$(v, { ".tag": "dotTag", "billing_address": "billingAddress", }); }); /** @internal */ export type PaymentMethodCreditCardInput$Outbound = { ".tag": string; billing_address: AddressReferenceInput$Outbound; network: string; bin: string; last4: string; expiration: string; token: string; }; /** @internal */ export const PaymentMethodCreditCardInput$outboundSchema: z.ZodType< PaymentMethodCreditCardInput$Outbound, z.ZodTypeDef, PaymentMethodCreditCardInput > = z.object({ dotTag: DotTag$outboundSchema, billingAddress: AddressReferenceInput$outboundSchema, network: CreditCardNetwork$outboundSchema, bin: z.string(), last4: z.string(), expiration: z.string(), token: z.string(), }).transform((v) => { return remap$(v, { dotTag: ".tag", billingAddress: "billing_address", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentMethodCreditCardInput$ { /** @deprecated use `PaymentMethodCreditCardInput$inboundSchema` instead. */ export const inboundSchema = PaymentMethodCreditCardInput$inboundSchema; /** @deprecated use `PaymentMethodCreditCardInput$outboundSchema` instead. */ export const outboundSchema = PaymentMethodCreditCardInput$outboundSchema; /** @deprecated use `PaymentMethodCreditCardInput$Outbound` instead. */ export type Outbound = PaymentMethodCreditCardInput$Outbound; } export function paymentMethodCreditCardInputToJSON( paymentMethodCreditCardInput: PaymentMethodCreditCardInput, ): string { return JSON.stringify( PaymentMethodCreditCardInput$outboundSchema.parse( paymentMethodCreditCardInput, ), ); } export function paymentMethodCreditCardInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentMethodCreditCardInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentMethodCreditCardInput' from JSON`, ); }