/* * 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 { CheckoutSortProperty, CheckoutSortProperty$outboundSchema, } from "../components/checkoutsortproperty.js"; import { CheckoutStatus, CheckoutStatus$outboundSchema, } from "../components/checkoutstatus.js"; import { ListResourceCheckout, ListResourceCheckout$inboundSchema, } from "../components/listresourcecheckout.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by organization ID. */ export type CheckoutsListQueryParamOrganizationIDFilter = | string | Array; /** * Filter by product ID. */ export type CheckoutsListQueryParamProductIDFilter = string | Array; /** * Filter by customer ID. */ export type CheckoutsListQueryParamCustomerIDFilter = string | Array; /** * Filter by customer external ID. */ export type CheckoutsListQueryParamExternalCustomerIDFilter = | string | Array; /** * Filter by checkout session status. */ export type QueryParamStatusFilter = CheckoutStatus | Array; export type CheckoutsListRequest = { /** * Filter by organization ID. */ organizationId?: string | Array | null | undefined; /** * Filter by product ID. */ productId?: 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 session status. */ status?: CheckoutStatus | Array | null | undefined; /** * Filter by customer email. */ query?: string | 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; }; export type CheckoutsListResponse = { result: ListResourceCheckout; }; /** @internal */ export type CheckoutsListQueryParamOrganizationIDFilter$Outbound = | string | Array; /** @internal */ export const CheckoutsListQueryParamOrganizationIDFilter$outboundSchema: z.ZodMiniType< CheckoutsListQueryParamOrganizationIDFilter$Outbound, CheckoutsListQueryParamOrganizationIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function checkoutsListQueryParamOrganizationIDFilterToJSON( checkoutsListQueryParamOrganizationIDFilter: CheckoutsListQueryParamOrganizationIDFilter, ): string { return JSON.stringify( CheckoutsListQueryParamOrganizationIDFilter$outboundSchema.parse( checkoutsListQueryParamOrganizationIDFilter, ), ); } /** @internal */ export type CheckoutsListQueryParamProductIDFilter$Outbound = | string | Array; /** @internal */ export const CheckoutsListQueryParamProductIDFilter$outboundSchema: z.ZodMiniType< CheckoutsListQueryParamProductIDFilter$Outbound, CheckoutsListQueryParamProductIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function checkoutsListQueryParamProductIDFilterToJSON( checkoutsListQueryParamProductIDFilter: CheckoutsListQueryParamProductIDFilter, ): string { return JSON.stringify( CheckoutsListQueryParamProductIDFilter$outboundSchema.parse( checkoutsListQueryParamProductIDFilter, ), ); } /** @internal */ export type CheckoutsListQueryParamCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const CheckoutsListQueryParamCustomerIDFilter$outboundSchema: z.ZodMiniType< CheckoutsListQueryParamCustomerIDFilter$Outbound, CheckoutsListQueryParamCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function checkoutsListQueryParamCustomerIDFilterToJSON( checkoutsListQueryParamCustomerIDFilter: CheckoutsListQueryParamCustomerIDFilter, ): string { return JSON.stringify( CheckoutsListQueryParamCustomerIDFilter$outboundSchema.parse( checkoutsListQueryParamCustomerIDFilter, ), ); } /** @internal */ export type CheckoutsListQueryParamExternalCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const CheckoutsListQueryParamExternalCustomerIDFilter$outboundSchema: z.ZodMiniType< CheckoutsListQueryParamExternalCustomerIDFilter$Outbound, CheckoutsListQueryParamExternalCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function checkoutsListQueryParamExternalCustomerIDFilterToJSON( checkoutsListQueryParamExternalCustomerIDFilter: CheckoutsListQueryParamExternalCustomerIDFilter, ): string { return JSON.stringify( CheckoutsListQueryParamExternalCustomerIDFilter$outboundSchema.parse( checkoutsListQueryParamExternalCustomerIDFilter, ), ); } /** @internal */ export type QueryParamStatusFilter$Outbound = string | Array; /** @internal */ export const QueryParamStatusFilter$outboundSchema: z.ZodMiniType< QueryParamStatusFilter$Outbound, QueryParamStatusFilter > = smartUnion([ CheckoutStatus$outboundSchema, z.array(CheckoutStatus$outboundSchema), ]); export function queryParamStatusFilterToJSON( queryParamStatusFilter: QueryParamStatusFilter, ): string { return JSON.stringify( QueryParamStatusFilter$outboundSchema.parse(queryParamStatusFilter), ); } /** @internal */ export type CheckoutsListRequest$Outbound = { organization_id?: string | Array | null | undefined; product_id?: string | Array | null | undefined; customer_id?: string | Array | null | undefined; external_customer_id?: string | Array | null | undefined; status?: string | Array | null | undefined; query?: string | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; }; /** @internal */ export const CheckoutsListRequest$outboundSchema: z.ZodMiniType< CheckoutsListRequest$Outbound, CheckoutsListRequest > = 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())])), ), customerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), externalCustomerId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), status: z.optional( z.nullable( smartUnion([ CheckoutStatus$outboundSchema, z.array(CheckoutStatus$outboundSchema), ]), ), ), query: z.optional(z.nullable(z.string())), page: z._default(z.int(), 1), limit: z._default(z.int(), 10), sorting: z.optional( z.nullable(z.array(CheckoutSortProperty$outboundSchema)), ), }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", productId: "product_id", customerId: "customer_id", externalCustomerId: "external_customer_id", }); }), ); export function checkoutsListRequestToJSON( checkoutsListRequest: CheckoutsListRequest, ): string { return JSON.stringify( CheckoutsListRequest$outboundSchema.parse(checkoutsListRequest), ); } /** @internal */ export const CheckoutsListResponse$inboundSchema: z.ZodMiniType< CheckoutsListResponse, unknown > = z.pipe( z.object({ Result: ListResourceCheckout$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function checkoutsListResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckoutsListResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckoutsListResponse' from JSON`, ); }