/* * 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 { PaymentMethodAffirm, PaymentMethodAffirm$inboundSchema, PaymentMethodAffirm$Outbound, PaymentMethodAffirm$outboundSchema, PaymentMethodAffirmTag, } from "./paymentmethodaffirmoutput.js"; import { PaymentMethodAfterpay, PaymentMethodAfterpay$inboundSchema, PaymentMethodAfterpay$Outbound, PaymentMethodAfterpay$outboundSchema, PaymentMethodAfterpayTag, } from "./paymentmethodafterpayoutput.js"; import { DotTag, PaymentMethodCreditCardInput, PaymentMethodCreditCardInput$inboundSchema, PaymentMethodCreditCardInput$Outbound, PaymentMethodCreditCardInput$outboundSchema, } from "./paymentmethodcreditcard.js"; import { PaymentMethodKlarnaAccount, PaymentMethodKlarnaAccount$inboundSchema, PaymentMethodKlarnaAccount$Outbound, PaymentMethodKlarnaAccount$outboundSchema, PaymentMethodKlarnaAccountTag, } from "./paymentmethodklarnaaccountoutput.js"; import { PaymentMethodKlarna, PaymentMethodKlarna$inboundSchema, PaymentMethodKlarna$Outbound, PaymentMethodKlarna$outboundSchema, PaymentMethodKlarnaTag, } from "./paymentmethodklarnaoutput.js"; import { PaymentMethodKlarnaPaynow, PaymentMethodKlarnaPaynow$inboundSchema, PaymentMethodKlarnaPaynow$Outbound, PaymentMethodKlarnaPaynow$outboundSchema, PaymentMethodKlarnaPaynowTag, } from "./paymentmethodklarnapaynowoutput.js"; import { PaymentMethodPaypal, PaymentMethodPaypal$inboundSchema, PaymentMethodPaypal$Outbound, PaymentMethodPaypal$outboundSchema, PaymentMethodPaypalTag, } from "./paymentmethodpaypaloutput.js"; import { PaymentMethodReference, PaymentMethodReference$inboundSchema, PaymentMethodReference$Outbound, PaymentMethodReference$outboundSchema, PaymentMethodReferenceTag, } from "./paymentmethodreference.js"; export type PaymentMethodExtended = | (PaymentMethodReference & { dotTag: PaymentMethodReferenceTag.Id }) | (PaymentMethodAffirm & { dotTag: PaymentMethodAffirmTag.Affirm }) | (PaymentMethodAfterpay & { dotTag: PaymentMethodAfterpayTag.Afterpay }) | (PaymentMethodKlarna & { dotTag: PaymentMethodKlarnaTag.Klarna }) | (PaymentMethodKlarnaAccount & { dotTag: PaymentMethodKlarnaAccountTag.KlarnaAccount; }) | (PaymentMethodKlarnaPaynow & { dotTag: PaymentMethodKlarnaPaynowTag.KlarnaPaynow; }) | (PaymentMethodPaypal & { dotTag: PaymentMethodPaypalTag.Paypal }) | (PaymentMethodCreditCardInput & { dotTag: DotTag.CreditCard }); /** @internal */ export const PaymentMethodExtended$inboundSchema: z.ZodType< PaymentMethodExtended, z.ZodTypeDef, unknown > = z.union([ PaymentMethodReference$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodReferenceTag.Id) }).transform(( v, ) => ({ dotTag: v[".tag"] })), ), PaymentMethodAffirm$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodAffirmTag.Affirm) }).transform(( v, ) => ({ dotTag: v[".tag"] })), ), PaymentMethodAfterpay$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodAfterpayTag.Afterpay) }) .transform((v) => ({ dotTag: v[".tag"] })), ), PaymentMethodKlarna$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodKlarnaTag.Klarna) }).transform(( v, ) => ({ dotTag: v[".tag"] })), ), PaymentMethodKlarnaAccount$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodKlarnaAccountTag.KlarnaAccount) }) .transform((v) => ({ dotTag: v[".tag"] })), ), PaymentMethodKlarnaPaynow$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodKlarnaPaynowTag.KlarnaPaynow) }) .transform((v) => ({ dotTag: v[".tag"] })), ), PaymentMethodPaypal$inboundSchema.and( z.object({ ".tag": z.literal(PaymentMethodPaypalTag.Paypal) }).transform(( v, ) => ({ dotTag: v[".tag"] })), ), PaymentMethodCreditCardInput$inboundSchema.and( z.object({ ".tag": z.literal(DotTag.CreditCard) }).transform((v) => ({ dotTag: v[".tag"], })), ), ]); /** @internal */ export type PaymentMethodExtended$Outbound = | (PaymentMethodReference$Outbound & { ".tag": PaymentMethodReferenceTag.Id }) | (PaymentMethodAffirm$Outbound & { ".tag": PaymentMethodAffirmTag.Affirm }) | (PaymentMethodAfterpay$Outbound & { ".tag": PaymentMethodAfterpayTag.Afterpay; }) | (PaymentMethodKlarna$Outbound & { ".tag": PaymentMethodKlarnaTag.Klarna }) | (PaymentMethodKlarnaAccount$Outbound & { ".tag": PaymentMethodKlarnaAccountTag.KlarnaAccount; }) | (PaymentMethodKlarnaPaynow$Outbound & { ".tag": PaymentMethodKlarnaPaynowTag.KlarnaPaynow; }) | (PaymentMethodPaypal$Outbound & { ".tag": PaymentMethodPaypalTag.Paypal }) | (PaymentMethodCreditCardInput$Outbound & { ".tag": DotTag.CreditCard }); /** @internal */ export const PaymentMethodExtended$outboundSchema: z.ZodType< PaymentMethodExtended$Outbound, z.ZodTypeDef, PaymentMethodExtended > = z.union([ PaymentMethodReference$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodReferenceTag.Id) }).transform(( v, ) => ({ ".tag": v.dotTag })), ), PaymentMethodAffirm$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodAffirmTag.Affirm) }).transform(( v, ) => ({ ".tag": v.dotTag })), ), PaymentMethodAfterpay$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodAfterpayTag.Afterpay) }) .transform((v) => ({ ".tag": v.dotTag })), ), PaymentMethodKlarna$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodKlarnaTag.Klarna) }).transform(( v, ) => ({ ".tag": v.dotTag })), ), PaymentMethodKlarnaAccount$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodKlarnaAccountTag.KlarnaAccount) }) .transform((v) => ({ ".tag": v.dotTag })), ), PaymentMethodKlarnaPaynow$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodKlarnaPaynowTag.KlarnaPaynow) }) .transform((v) => ({ ".tag": v.dotTag })), ), PaymentMethodPaypal$outboundSchema.and( z.object({ dotTag: z.literal(PaymentMethodPaypalTag.Paypal) }).transform(( v, ) => ({ ".tag": v.dotTag })), ), PaymentMethodCreditCardInput$outboundSchema.and( z.object({ dotTag: z.literal(DotTag.CreditCard) }).transform((v) => ({ ".tag": v.dotTag, })), ), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentMethodExtended$ { /** @deprecated use `PaymentMethodExtended$inboundSchema` instead. */ export const inboundSchema = PaymentMethodExtended$inboundSchema; /** @deprecated use `PaymentMethodExtended$outboundSchema` instead. */ export const outboundSchema = PaymentMethodExtended$outboundSchema; /** @deprecated use `PaymentMethodExtended$Outbound` instead. */ export type Outbound = PaymentMethodExtended$Outbound; } export function paymentMethodExtendedToJSON( paymentMethodExtended: PaymentMethodExtended, ): string { return JSON.stringify( PaymentMethodExtended$outboundSchema.parse(paymentMethodExtended), ); } export function paymentMethodExtendedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentMethodExtended$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentMethodExtended' from JSON`, ); }