/* * 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 { InvoiceStatus, InvoiceStatus$inboundSchema, } from "./invoice-status.js"; import { InvoiceType, InvoiceType$inboundSchema } from "./invoice-type.js"; import { PaymentStatus, PaymentStatus$inboundSchema, } from "./payment-status.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { WebhookDtoCustomer, WebhookDtoCustomer$inboundSchema, } from "./webhook-dto-customer.js"; import { WebhookDtoInvoiceLineItem, WebhookDtoInvoiceLineItem$inboundSchema, } from "./webhook-dto-invoice-line-item.js"; import { WebhookDtoSubscription, WebhookDtoSubscription$inboundSchema, } from "./webhook-dto-subscription.js"; export type WebhookDtoInvoice = { amountDue?: string | undefined; amountPaid?: string | undefined; amountRemaining?: string | undefined; billingReason?: string | undefined; currency?: string | undefined; customer?: WebhookDtoCustomer | undefined; customerId?: string | undefined; dueDate?: Date | undefined; environmentId?: string | undefined; finalizedAt?: Date | undefined; id?: string | undefined; invoiceNumber?: string | undefined; invoicePdfUrl?: string | undefined; invoiceStatus?: InvoiceStatus | undefined; invoiceType?: InvoiceType | undefined; lineItems?: Array | undefined; metadata?: { [k: string]: string } | undefined; paidAt?: Date | undefined; paymentStatus?: PaymentStatus | undefined; periodEnd?: Date | undefined; periodStart?: Date | undefined; subscription?: WebhookDtoSubscription | undefined; subscriptionId?: string | undefined; subtotal?: string | undefined; total?: string | undefined; voidedAt?: Date | undefined; }; /** @internal */ export const WebhookDtoInvoice$inboundSchema: z.ZodMiniType< WebhookDtoInvoice, unknown > = z.pipe( z.object({ amount_due: types.optional(types.string()), amount_paid: types.optional(types.string()), amount_remaining: types.optional(types.string()), billing_reason: types.optional(types.string()), currency: types.optional(types.string()), customer: types.optional(WebhookDtoCustomer$inboundSchema), customer_id: types.optional(types.string()), due_date: types.optional(types.date()), environment_id: types.optional(types.string()), finalized_at: types.optional(types.date()), id: types.optional(types.string()), invoice_number: types.optional(types.string()), invoice_pdf_url: types.optional(types.string()), invoice_status: types.optional(InvoiceStatus$inboundSchema), invoice_type: types.optional(InvoiceType$inboundSchema), line_items: types.optional( z.array(WebhookDtoInvoiceLineItem$inboundSchema), ), metadata: types.optional(z.record(z.string(), types.string())), paid_at: types.optional(types.date()), payment_status: types.optional(PaymentStatus$inboundSchema), period_end: types.optional(types.date()), period_start: types.optional(types.date()), subscription: types.optional(WebhookDtoSubscription$inboundSchema), subscription_id: types.optional(types.string()), subtotal: types.optional(types.string()), total: types.optional(types.string()), voided_at: types.optional(types.date()), }), z.transform((v) => { return remap$(v, { "amount_due": "amountDue", "amount_paid": "amountPaid", "amount_remaining": "amountRemaining", "billing_reason": "billingReason", "customer_id": "customerId", "due_date": "dueDate", "environment_id": "environmentId", "finalized_at": "finalizedAt", "invoice_number": "invoiceNumber", "invoice_pdf_url": "invoicePdfUrl", "invoice_status": "invoiceStatus", "invoice_type": "invoiceType", "line_items": "lineItems", "paid_at": "paidAt", "payment_status": "paymentStatus", "period_end": "periodEnd", "period_start": "periodStart", "subscription_id": "subscriptionId", "voided_at": "voidedAt", }); }), ); export function webhookDtoInvoiceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookDtoInvoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookDtoInvoice' from JSON`, ); }