/* * 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 { ClosedEnum } from "../../types/enums.js"; import { FilterCondition, FilterCondition$Outbound, FilterCondition$outboundSchema, } from "./filter-condition.js"; import { InvoiceBillingReason, InvoiceBillingReason$outboundSchema, } from "./invoice-billing-reason.js"; import { InvoiceStatus, InvoiceStatus$outboundSchema, } from "./invoice-status.js"; import { InvoiceType, InvoiceType$outboundSchema } from "./invoice-type.js"; import { PaymentStatus, PaymentStatus$outboundSchema, } from "./payment-status.js"; import { SortCondition, SortCondition$Outbound, SortCondition$outboundSchema, } from "./sort-condition.js"; import { Status, Status$outboundSchema } from "./status.js"; export const InvoiceFilterOrder = { Asc: "asc", Desc: "desc", } as const; export type InvoiceFilterOrder = ClosedEnum; export type InvoiceFilter = { /** * amount_due_gt filters invoices with a total amount due greater than the specified value * * @remarks * Useful for finding invoices above a certain threshold or identifying high-value invoices */ amountDueGt?: number | undefined; /** * amount_remaining_gt filters invoices with an outstanding balance greater than the specified value * * @remarks * Useful for finding invoices that still have significant unpaid amounts */ amountRemainingGt?: number | undefined; billingReason?: InvoiceBillingReason | undefined; /** * currency filters invoices by their currency (ISO 4217 code, e.g. "usd", "eur"). * * @remarks * Matches on the invoices.currency column exactly. */ currency?: string | undefined; /** * customer_id filters invoices for a specific customer using FlexPrice's internal customer ID * * @remarks * This is the ID returned by FlexPrice when creating or retrieving customers */ customerId?: string | undefined; endTime?: Date | undefined; expand?: string | undefined; /** * external_customer_id filters invoices for a customer using your system's customer identifier * * @remarks * This is the ID you provided when creating the customer in FlexPrice */ externalCustomerId?: string | undefined; filters?: Array | undefined; /** * invoice_ids restricts results to invoices with the specified IDs * * @remarks * Use this to retrieve specific invoices when you know their exact identifiers */ invoiceIds?: Array | undefined; /** * invoice_status filters by the current state of invoices in their lifecycle * * @remarks * Multiple statuses can be specified to include invoices in any of the listed states */ invoiceStatus?: Array | undefined; invoiceType?: InvoiceType | undefined; limit?: number | undefined; offset?: number | undefined; order?: InvoiceFilterOrder | undefined; /** * payment_status filters by the payment state of invoices * * @remarks * Multiple statuses can be specified to include invoices with any of the listed payment states */ paymentStatus?: Array | undefined; /** * period_end_gte filters invoices with period_end >= value */ periodEndGte?: string | undefined; /** * period_end_lte filters invoices with period_end <= value */ periodEndLte?: string | undefined; /** * period_start_gte filters invoices with period_start >= value */ periodStartGte?: string | undefined; /** * period_start_lte filters invoices with period_start <= value */ periodStartLte?: string | undefined; /** * SkipLineItems if true, will not include line items in the response */ skipLineItems?: boolean | undefined; sort?: Array | undefined; startTime?: Date | undefined; status?: Status | undefined; /** * subscription_customer_id filters invoices by the subscription owner's customer ID */ subscriptionCustomerId?: Array | undefined; /** * subscription_id filters invoices generated for a specific subscription * * @remarks * Only returns invoices that were created as part of the specified subscription's billing */ subscriptionId?: string | undefined; }; /** @internal */ export const InvoiceFilterOrder$outboundSchema: z.ZodMiniEnum< typeof InvoiceFilterOrder > = z.enum(InvoiceFilterOrder); /** @internal */ export type InvoiceFilter$Outbound = { amount_due_gt?: number | undefined; amount_remaining_gt?: number | undefined; billing_reason?: string | undefined; currency?: string | undefined; customer_id?: string | undefined; end_time?: string | undefined; expand?: string | undefined; external_customer_id?: string | undefined; filters?: Array | undefined; invoice_ids?: Array | undefined; invoice_status?: Array | undefined; invoice_type?: string | undefined; limit?: number | undefined; offset?: number | undefined; order?: string | undefined; payment_status?: Array | undefined; period_end_gte?: string | undefined; period_end_lte?: string | undefined; period_start_gte?: string | undefined; period_start_lte?: string | undefined; skip_line_items?: boolean | undefined; sort?: Array | undefined; start_time?: string | undefined; status?: string | undefined; subscription_customer_id?: Array | undefined; subscription_id?: string | undefined; }; /** @internal */ export const InvoiceFilter$outboundSchema: z.ZodMiniType< InvoiceFilter$Outbound, InvoiceFilter > = z.pipe( z.object({ amountDueGt: z.optional(z.number()), amountRemainingGt: z.optional(z.number()), billingReason: z.optional(InvoiceBillingReason$outboundSchema), currency: z.optional(z.string()), customerId: z.optional(z.string()), endTime: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))), expand: z.optional(z.string()), externalCustomerId: z.optional(z.string()), filters: z.optional(z.array(FilterCondition$outboundSchema)), invoiceIds: z.optional(z.array(z.string())), invoiceStatus: z.optional(z.array(InvoiceStatus$outboundSchema)), invoiceType: z.optional(InvoiceType$outboundSchema), limit: z.optional(z.int()), offset: z.optional(z.int()), order: z.optional(InvoiceFilterOrder$outboundSchema), paymentStatus: z.optional(z.array(PaymentStatus$outboundSchema)), periodEndGte: z.optional(z.string()), periodEndLte: z.optional(z.string()), periodStartGte: z.optional(z.string()), periodStartLte: z.optional(z.string()), skipLineItems: z.optional(z.boolean()), sort: z.optional(z.array(SortCondition$outboundSchema)), startTime: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))), status: z.optional(Status$outboundSchema), subscriptionCustomerId: z.optional(z.array(z.string())), subscriptionId: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { amountDueGt: "amount_due_gt", amountRemainingGt: "amount_remaining_gt", billingReason: "billing_reason", customerId: "customer_id", endTime: "end_time", externalCustomerId: "external_customer_id", invoiceIds: "invoice_ids", invoiceStatus: "invoice_status", invoiceType: "invoice_type", paymentStatus: "payment_status", periodEndGte: "period_end_gte", periodEndLte: "period_end_lte", periodStartGte: "period_start_gte", periodStartLte: "period_start_lte", skipLineItems: "skip_line_items", startTime: "start_time", subscriptionCustomerId: "subscription_customer_id", subscriptionId: "subscription_id", }); }), ); export function invoiceFilterToJSON(invoiceFilter: InvoiceFilter): string { return JSON.stringify(InvoiceFilter$outboundSchema.parse(invoiceFilter)); }