/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; 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 { DisputeStatus, DisputeStatus$inboundSchema } from "./disputestatus.js"; /** * Schema representing a dispute. * * @remarks * * A dispute is a challenge raised by a customer or their bank regarding a payment. */ export type Dispute = { /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The ID of the object. */ id: string; status: DisputeStatus; /** * Whether the dispute has been resolved (won or lost). */ resolved: boolean; /** * Whether the dispute is closed (prevented, won, or lost). */ closed: boolean; /** * Amount in cents disputed. */ amount: number; /** * Tax amount in cents disputed. */ taxAmount: number; /** * Currency code of the dispute. */ currency: string; /** * The ID of the order associated with the dispute. */ orderId: string; /** * The ID of the payment associated with the dispute. */ paymentId: string; }; /** @internal */ export const Dispute$inboundSchema: z.ZodMiniType = z.pipe( z.object({ created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), id: z.string(), status: DisputeStatus$inboundSchema, resolved: z.boolean(), closed: z.boolean(), amount: z.int(), tax_amount: z.int(), currency: z.string(), order_id: z.string(), payment_id: z.string(), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "tax_amount": "taxAmount", "order_id": "orderId", "payment_id": "paymentId", }); }), ); export function disputeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Dispute$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Dispute' from JSON`, ); }