/* * 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 { CreditnoteCreditNoteLineItem, CreditnoteCreditNoteLineItem$inboundSchema, } from "./creditnote-credit-note-line-item.js"; import { Customer, Customer$inboundSchema } from "./customer.js"; import { InvoiceResponse, InvoiceResponse$inboundSchema, } from "./invoice-response.js"; import { PaymentStatus, PaymentStatus$inboundSchema, } from "./payment-status.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { Status, Status$inboundSchema } from "./status.js"; import { SubscriptionResponse, SubscriptionResponse$inboundSchema, } from "./subscription-response.js"; export type CreditNoteResponse = { createdAt?: Date | undefined; createdBy?: string | undefined; /** * credit_note_number is the unique identifier for credit notes */ creditNoteNumber?: string | undefined; creditNoteStatus?: CreditNoteStatus | undefined; creditNoteType?: CreditNoteType | undefined; /** * currency is the three-letter ISO currency code (e.g., USD, EUR) for the credit note */ currency?: string | undefined; customer?: Customer | undefined; /** * customer_id is the unique identifier of the customer who owns this credit note */ customerId?: string | undefined; /** * environment_id is the unique identifier of the environment this credit note belongs to */ environmentId?: string | undefined; /** * finalized_at is the timestamp when the credit note was finalized */ finalizedAt?: Date | undefined; /** * id is the unique identifier for the credit note */ id?: string | undefined; /** * idempotency_key is an optional key used to prevent duplicate credit note creation */ idempotencyKey?: string | undefined; invoice?: InvoiceResponse | undefined; /** * invoice_id is the id of the invoice resource that this credit note is applied to */ invoiceId?: string | undefined; /** * line_items contains all of the line items associated with this credit note */ lineItems?: Array | undefined; /** * memo is an optional memo supplied on the credit note */ memo?: string | undefined; metadata?: { [k: string]: string } | undefined; reason?: CreditNoteReason | undefined; refundStatus?: PaymentStatus | undefined; status?: Status | undefined; subscription?: SubscriptionResponse | undefined; /** * subscription_id is the optional unique identifier of the subscription related to this credit note */ subscriptionId?: string | undefined; tenantId?: string | undefined; /** * total_amount is the total including creditable invoice-level discounts or minimums, and tax */ totalAmount?: string | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; /** * voided_at is the timestamp when the credit note was voided */ voidedAt?: Date | undefined; }; /** @internal */ export const CreditNoteResponse$inboundSchema: z.ZodMiniType< CreditNoteResponse, unknown > = z.pipe( z.object({ created_at: types.optional(types.date()), created_by: types.optional(types.string()), 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: types.optional(Customer$inboundSchema), customer_id: types.optional(types.string()), environment_id: types.optional(types.string()), finalized_at: types.optional(types.date()), id: types.optional(types.string()), idempotency_key: types.optional(types.string()), invoice: types.optional(InvoiceResponse$inboundSchema), invoice_id: types.optional(types.string()), line_items: types.optional( z.array(CreditnoteCreditNoteLineItem$inboundSchema), ), memo: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), reason: types.optional(CreditNoteReason$inboundSchema), refund_status: types.optional(PaymentStatus$inboundSchema), status: types.optional(Status$inboundSchema), subscription: types.optional(SubscriptionResponse$inboundSchema), subscription_id: types.optional(types.string()), tenant_id: types.optional(types.string()), total_amount: types.optional(types.string()), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), voided_at: types.optional(types.date()), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "created_by": "createdBy", "credit_note_number": "creditNoteNumber", "credit_note_status": "creditNoteStatus", "credit_note_type": "creditNoteType", "customer_id": "customerId", "environment_id": "environmentId", "finalized_at": "finalizedAt", "idempotency_key": "idempotencyKey", "invoice_id": "invoiceId", "line_items": "lineItems", "refund_status": "refundStatus", "subscription_id": "subscriptionId", "tenant_id": "tenantId", "total_amount": "totalAmount", "updated_at": "updatedAt", "updated_by": "updatedBy", "voided_at": "voidedAt", }); }), ); export function creditNoteResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreditNoteResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditNoteResponse' from JSON`, ); }