/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import * as components from "../components/index.js"; import { MoovError } from "./mooverror.js"; /** * Details of a card refund. */ export type CardAcquiringRefundData = { /** * Identifier for the refund. */ refundID: string; createdOn: Date; updatedOn: Date; status: components.RefundStatus; amount: components.Amount; cardDetails?: components.RefundCardDetails | undefined; }; /** * Details of a card refund. */ export class CardAcquiringRefund extends MoovError { /** * Identifier for the refund. */ refundID: string; createdOn: Date; updatedOn: Date; status: components.RefundStatus; amount: components.Amount; cardDetails?: components.RefundCardDetails | undefined; /** The original data that was passed to this error instance. */ data$: CardAcquiringRefundData; constructor( err: CardAcquiringRefundData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.refundID = err.refundID; this.createdOn = err.createdOn; this.updatedOn = err.updatedOn; this.status = err.status; this.amount = err.amount; if (err.cardDetails != null) this.cardDetails = err.cardDetails; this.name = "CardAcquiringRefund"; } } /** @internal */ export const CardAcquiringRefund$inboundSchema: z.ZodType< CardAcquiringRefund, z.ZodTypeDef, unknown > = z.object({ refundID: z.string(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), updatedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), status: components.RefundStatus$inboundSchema, amount: components.Amount$inboundSchema, cardDetails: components.RefundCardDetails$inboundSchema.optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new CardAcquiringRefund(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type CardAcquiringRefund$Outbound = { refundID: string; createdOn: string; updatedOn: string; status: string; amount: components.Amount$Outbound; cardDetails?: components.RefundCardDetails$Outbound | undefined; }; /** @internal */ export const CardAcquiringRefund$outboundSchema: z.ZodType< CardAcquiringRefund$Outbound, z.ZodTypeDef, CardAcquiringRefund > = z.instanceof(CardAcquiringRefund) .transform(v => v.data$) .pipe(z.object({ refundID: z.string(), createdOn: z.date().transform(v => v.toISOString()), updatedOn: z.date().transform(v => v.toISOString()), status: components.RefundStatus$outboundSchema, amount: components.Amount$outboundSchema, cardDetails: components.RefundCardDetails$outboundSchema.optional(), }));