/* * 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 { smartUnion } from "../../types/smartUnion.js"; import { ListResourceOrder, ListResourceOrder$inboundSchema, } from "../components/listresourceorder.js"; import { OrderSortProperty, OrderSortProperty$outboundSchema, } from "../components/ordersortproperty.js"; import { ProductBillingType, ProductBillingType$outboundSchema, } from "../components/productbillingtype.js"; import { MetadataQuery, MetadataQuery$Outbound, MetadataQuery$outboundSchema, } from "../components/subscriptionslist.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by organization ID. */ export type OrdersListQueryParamOrganizationIDFilter = string | Array; /** * Filter by product ID. */ export type OrdersListQueryParamProductIDFilter = string | Array; /** * Filter by product billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases. */ export type ProductBillingTypeFilter = | ProductBillingType | Array; /** * Filter by discount ID. */ export type QueryParamDiscountIDFilter = string | Array; /** * Filter by customer ID. */ export type OrdersListQueryParamCustomerIDFilter = string | Array; /** * Filter by customer external ID. */ export type OrdersListQueryParamExternalCustomerIDFilter = | string | Array; /** * Filter by checkout ID. */ export type CheckoutIDFilter = string | Array; /** * Filter by subscription ID. */ export type SubscriptionIDFilter = string | Array; export type OrdersListRequest = { /** * Filter by organization ID. */ organizationId?: string | Array | null | undefined; /** * Filter by product ID. */ productId?: string | Array | null | undefined; /** * Filter by product billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases. */ productBillingType?: | ProductBillingType | Array | null | undefined; /** * Filter by discount ID. */ discountId?: string | Array | null | undefined; /** * Filter by customer ID. */ customerId?: string | Array | null | undefined; /** * Filter by customer external ID. */ externalCustomerId?: string | Array | null | undefined; /** * Filter by checkout ID. */ checkoutId?: string | Array | null | undefined; /** * Filter by subscription ID. */ subscriptionId?: string | Array | null | undefined; /** * Page number, defaults to 1. */ page?: number | undefined; /** * Size of a page, defaults to 10. Maximum is 100. */ limit?: number | undefined; /** * Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign `-` before the criteria name to sort by descending order. */ sorting?: Array | null | undefined; /** * Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`. */ metadata?: { [k: string]: MetadataQuery } | null | undefined; }; export type OrdersListResponse = { result: ListResourceOrder; }; /** @internal */ export type OrdersListQueryParamOrganizationIDFilter$Outbound = | string | Array; /** @internal */ export const OrdersListQueryParamOrganizationIDFilter$outboundSchema: z.ZodMiniType< OrdersListQueryParamOrganizationIDFilter$Outbound, OrdersListQueryParamOrganizationIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function ordersListQueryParamOrganizationIDFilterToJSON( ordersListQueryParamOrganizationIDFilter: OrdersListQueryParamOrganizationIDFilter, ): string { return JSON.stringify( OrdersListQueryParamOrganizationIDFilter$outboundSchema.parse( ordersListQueryParamOrganizationIDFilter, ), ); } /** @internal */ export type OrdersListQueryParamProductIDFilter$Outbound = | string | Array; /** @internal */ export const OrdersListQueryParamProductIDFilter$outboundSchema: z.ZodMiniType< OrdersListQueryParamProductIDFilter$Outbound, OrdersListQueryParamProductIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function ordersListQueryParamProductIDFilterToJSON( ordersListQueryParamProductIDFilter: OrdersListQueryParamProductIDFilter, ): string { return JSON.stringify( OrdersListQueryParamProductIDFilter$outboundSchema.parse( ordersListQueryParamProductIDFilter, ), ); } /** @internal */ export type ProductBillingTypeFilter$Outbound = string | Array; /** @internal */ export const ProductBillingTypeFilter$outboundSchema: z.ZodMiniType< ProductBillingTypeFilter$Outbound, ProductBillingTypeFilter > = smartUnion([ ProductBillingType$outboundSchema, z.array(ProductBillingType$outboundSchema), ]); export function productBillingTypeFilterToJSON( productBillingTypeFilter: ProductBillingTypeFilter, ): string { return JSON.stringify( ProductBillingTypeFilter$outboundSchema.parse(productBillingTypeFilter), ); } /** @internal */ export type QueryParamDiscountIDFilter$Outbound = string | Array; /** @internal */ export const QueryParamDiscountIDFilter$outboundSchema: z.ZodMiniType< QueryParamDiscountIDFilter$Outbound, QueryParamDiscountIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function queryParamDiscountIDFilterToJSON( queryParamDiscountIDFilter: QueryParamDiscountIDFilter, ): string { return JSON.stringify( QueryParamDiscountIDFilter$outboundSchema.parse(queryParamDiscountIDFilter), ); } /** @internal */ export type OrdersListQueryParamCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const OrdersListQueryParamCustomerIDFilter$outboundSchema: z.ZodMiniType< OrdersListQueryParamCustomerIDFilter$Outbound, OrdersListQueryParamCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function ordersListQueryParamCustomerIDFilterToJSON( ordersListQueryParamCustomerIDFilter: OrdersListQueryParamCustomerIDFilter, ): string { return JSON.stringify( OrdersListQueryParamCustomerIDFilter$outboundSchema.parse( ordersListQueryParamCustomerIDFilter, ), ); } /** @internal */ export type OrdersListQueryParamExternalCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const OrdersListQueryParamExternalCustomerIDFilter$outboundSchema: z.ZodMiniType< OrdersListQueryParamExternalCustomerIDFilter$Outbound, OrdersListQueryParamExternalCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function ordersListQueryParamExternalCustomerIDFilterToJSON( ordersListQueryParamExternalCustomerIDFilter: OrdersListQueryParamExternalCustomerIDFilter, ): string { return JSON.stringify( OrdersListQueryParamExternalCustomerIDFilter$outboundSchema.parse( ordersListQueryParamExternalCustomerIDFilter, ), ); } /** @internal */ export type CheckoutIDFilter$Outbound = string | Array; /** @internal */ export const CheckoutIDFilter$outboundSchema: z.ZodMiniType< CheckoutIDFilter$Outbound, CheckoutIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function checkoutIDFilterToJSON( checkoutIDFilter: CheckoutIDFilter, ): string { return JSON.stringify( CheckoutIDFilter$outboundSchema.parse(checkoutIDFilter), ); } /** @internal */ export type SubscriptionIDFilter$Outbound = string | Array; /** @internal */ export const SubscriptionIDFilter$outboundSchema: z.ZodMiniType< SubscriptionIDFilter$Outbound, SubscriptionIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function subscriptionIDFilterToJSON( subscriptionIDFilter: SubscriptionIDFilter, ): string { return JSON.stringify( SubscriptionIDFilter$outboundSchema.parse(subscriptionIDFilter), ); } /** @internal */ export type OrdersListRequest$Outbound = { organization_id?: string | Array | null | undefined; product_id?: string | Array | null | undefined; product_billing_type?: string | Array | null | undefined; discount_id?: string | Array | null | undefined; customer_id?: string | Array | null | undefined; external_customer_id?: string | Array | null | undefined; checkout_id?: string | Array | null | undefined; subscription_id?: string | Array | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; metadata?: { [k: string]: MetadataQuery$Outbound } | null | undefined; }; /** @internal */ export const OrdersListRequest$outboundSchema: z.ZodMiniType< OrdersListRequest$Outbound, OrdersListRequest > = z.pipe( z.object({ organizationId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), productId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), productBillingType: z.optional( z.nullable( smartUnion([ ProductBillingType$outboundSchema, z.array(ProductBillingType$outboundSchema), ]), ), ), discountId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), customerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), externalCustomerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), checkoutId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), subscriptionId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), page: z._default(z.int(), 1), limit: z._default(z.int(), 10), sorting: z.optional(z.nullable(z.array(OrderSortProperty$outboundSchema))), metadata: z.optional( z.nullable(z.record(z.string(), MetadataQuery$outboundSchema)), ), }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", productId: "product_id", productBillingType: "product_billing_type", discountId: "discount_id", customerId: "customer_id", externalCustomerId: "external_customer_id", checkoutId: "checkout_id", subscriptionId: "subscription_id", }); }), ); export function ordersListRequestToJSON( ordersListRequest: OrdersListRequest, ): string { return JSON.stringify( OrdersListRequest$outboundSchema.parse(ordersListRequest), ); } /** @internal */ export const OrdersListResponse$inboundSchema: z.ZodMiniType< OrdersListResponse, unknown > = z.pipe( z.object({ Result: ListResourceOrder$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function ordersListResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OrdersListResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OrdersListResponse' from JSON`, ); }