/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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"; /** * A settlement record for a refund on a transaction. */ export type RefundSettlement = { /** * The unique identifier for the record. */ id: string; /** * The merchant account this record belongs to. */ merchantAccountId: string; /** * The date and time the record was created, in ISO 8601 format. */ createdAt: Date; /** * The date and time the record was last updated, in ISO 8601 format. */ updatedAt: Date; /** * The date and time the record was posted, in ISO 8601 format. */ postedAt: Date; /** * The date and time the record was ingested, in ISO 8601 format. */ ingestedAt: Date; /** * ISO 4217 currency code. */ currency: string; /** * The total amount in the smallest currency unit (e.g. cents). */ amount: number; /** * The exchange rate, if applicable. */ exchangeRate?: number | null | undefined; /** * The commission amount deducted in the smallest currency unit. */ commission: number; /** * The interchange fee, if applicable, in the smallest currency unit. */ interchange?: number | null | undefined; /** * The markup fee, if applicable, in the smallest currency unit. */ markup?: number | null | undefined; /** * The scheme fee, if applicable, in the smallest currency unit. */ schemeFee?: number | null | undefined; /** * The report ID from the payment service. */ paymentServiceReportId: string; /** * List of file IDs for the payment service report. */ paymentServiceReportFileIds: Array; /** * The transaction this record is associated with. */ transactionId: string; /** * Always `refund-settlement`. */ type: "refund-settlement"; /** * The refund this settlement is associated with. */ refundId: string; }; /** @internal */ export const RefundSettlement$inboundSchema: z.ZodType< RefundSettlement, z.ZodTypeDef, unknown > = z.object({ id: z.string(), merchant_account_id: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), posted_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), ingested_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), currency: z.string(), amount: z.number().int(), exchange_rate: z.nullable(z.number()).optional(), commission: z.number().int(), interchange: z.nullable(z.number().int()).optional(), markup: z.nullable(z.number().int()).optional(), scheme_fee: z.nullable(z.number().int()).optional(), payment_service_report_id: z.string(), payment_service_report_file_ids: z.array(z.string()), transaction_id: z.string(), type: z.literal("refund-settlement").default("refund-settlement"), refund_id: z.string(), }).transform((v) => { return remap$(v, { "merchant_account_id": "merchantAccountId", "created_at": "createdAt", "updated_at": "updatedAt", "posted_at": "postedAt", "ingested_at": "ingestedAt", "exchange_rate": "exchangeRate", "scheme_fee": "schemeFee", "payment_service_report_id": "paymentServiceReportId", "payment_service_report_file_ids": "paymentServiceReportFileIds", "transaction_id": "transactionId", "refund_id": "refundId", }); }); export function refundSettlementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RefundSettlement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RefundSettlement' from JSON`, ); }