/* * 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 * as types from "../../types/primitives.js"; import { CreditNoteReason, CreditNoteReason$inboundSchema, } from "./credit-note-reason.js"; import { CreditNoteStatus, CreditNoteStatus$inboundSchema, } from "./credit-note-status.js"; import { CreditNoteType, CreditNoteType$inboundSchema, } from "./credit-note-type.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type WebhookDtoCreditNote = { creditNoteNumber?: string | undefined; creditNoteStatus?: CreditNoteStatus | undefined; creditNoteType?: CreditNoteType | undefined; currency?: string | undefined; customerId?: string | undefined; finalizedAt?: Date | undefined; id?: string | undefined; invoiceId?: string | undefined; memo?: string | undefined; metadata?: { [k: string]: string } | undefined; reason?: CreditNoteReason | undefined; subscriptionId?: string | undefined; totalAmount?: string | undefined; voidedAt?: Date | undefined; }; /** @internal */ export const WebhookDtoCreditNote$inboundSchema: z.ZodMiniType< WebhookDtoCreditNote, unknown > = z.pipe( z.object({ credit_note_number: types.optional(types.string()), credit_note_status: types.optional(CreditNoteStatus$inboundSchema), credit_note_type: types.optional(CreditNoteType$inboundSchema), currency: types.optional(types.string()), customer_id: types.optional(types.string()), finalized_at: types.optional(types.date()), id: types.optional(types.string()), invoice_id: types.optional(types.string()), memo: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), reason: types.optional(CreditNoteReason$inboundSchema), subscription_id: types.optional(types.string()), total_amount: types.optional(types.string()), voided_at: types.optional(types.date()), }), z.transform((v) => { return remap$(v, { "credit_note_number": "creditNoteNumber", "credit_note_status": "creditNoteStatus", "credit_note_type": "creditNoteType", "customer_id": "customerId", "finalized_at": "finalizedAt", "invoice_id": "invoiceId", "subscription_id": "subscriptionId", "total_amount": "totalAmount", "voided_at": "voidedAt", }); }), ); export function webhookDtoCreditNoteFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookDtoCreditNote$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookDtoCreditNote' from JSON`, ); }