/* * 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 { CustomerOrderSortProperty, CustomerOrderSortProperty$outboundSchema, } from "../components/customerordersortproperty.js"; import { ListResourceCustomerOrder, ListResourceCustomerOrder$inboundSchema, } from "../components/listresourcecustomerorder.js"; import { ProductBillingType, ProductBillingType$outboundSchema, } from "../components/productbillingtype.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CustomerPortalOrdersListSecurity = { customerSession?: string | undefined; memberSession?: string | undefined; }; /** * Filter by product ID. */ export type CustomerPortalOrdersListQueryParamProductIDFilter = | 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 CustomerPortalOrdersListQueryParamProductBillingTypeFilter = | ProductBillingType | Array; /** * Filter by subscription ID. */ export type CustomerPortalOrdersListQueryParamSubscriptionIDFilter = | string | Array; export type CustomerPortalOrdersListRequest = { /** * 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 subscription ID. */ subscriptionId?: string | Array | null | undefined; /** * Search by product or organization name. */ 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 CustomerPortalOrdersListResponse = { result: ListResourceCustomerOrder; }; /** @internal */ export type CustomerPortalOrdersListSecurity$Outbound = { customer_session?: string | undefined; member_session?: string | undefined; }; /** @internal */ export const CustomerPortalOrdersListSecurity$outboundSchema: z.ZodMiniType< CustomerPortalOrdersListSecurity$Outbound, CustomerPortalOrdersListSecurity > = z.pipe( z.object({ customerSession: z.optional(z.string()), memberSession: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { customerSession: "customer_session", memberSession: "member_session", }); }), ); export function customerPortalOrdersListSecurityToJSON( customerPortalOrdersListSecurity: CustomerPortalOrdersListSecurity, ): string { return JSON.stringify( CustomerPortalOrdersListSecurity$outboundSchema.parse( customerPortalOrdersListSecurity, ), ); } /** @internal */ export type CustomerPortalOrdersListQueryParamProductIDFilter$Outbound = | string | Array; /** @internal */ export const CustomerPortalOrdersListQueryParamProductIDFilter$outboundSchema: z.ZodMiniType< CustomerPortalOrdersListQueryParamProductIDFilter$Outbound, CustomerPortalOrdersListQueryParamProductIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function customerPortalOrdersListQueryParamProductIDFilterToJSON( customerPortalOrdersListQueryParamProductIDFilter: CustomerPortalOrdersListQueryParamProductIDFilter, ): string { return JSON.stringify( CustomerPortalOrdersListQueryParamProductIDFilter$outboundSchema.parse( customerPortalOrdersListQueryParamProductIDFilter, ), ); } /** @internal */ export type CustomerPortalOrdersListQueryParamProductBillingTypeFilter$Outbound = | string | Array; /** @internal */ export const CustomerPortalOrdersListQueryParamProductBillingTypeFilter$outboundSchema: z.ZodMiniType< CustomerPortalOrdersListQueryParamProductBillingTypeFilter$Outbound, CustomerPortalOrdersListQueryParamProductBillingTypeFilter > = smartUnion([ ProductBillingType$outboundSchema, z.array(ProductBillingType$outboundSchema), ]); export function customerPortalOrdersListQueryParamProductBillingTypeFilterToJSON( customerPortalOrdersListQueryParamProductBillingTypeFilter: CustomerPortalOrdersListQueryParamProductBillingTypeFilter, ): string { return JSON.stringify( CustomerPortalOrdersListQueryParamProductBillingTypeFilter$outboundSchema .parse(customerPortalOrdersListQueryParamProductBillingTypeFilter), ); } /** @internal */ export type CustomerPortalOrdersListQueryParamSubscriptionIDFilter$Outbound = | string | Array; /** @internal */ export const CustomerPortalOrdersListQueryParamSubscriptionIDFilter$outboundSchema: z.ZodMiniType< CustomerPortalOrdersListQueryParamSubscriptionIDFilter$Outbound, CustomerPortalOrdersListQueryParamSubscriptionIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function customerPortalOrdersListQueryParamSubscriptionIDFilterToJSON( customerPortalOrdersListQueryParamSubscriptionIDFilter: CustomerPortalOrdersListQueryParamSubscriptionIDFilter, ): string { return JSON.stringify( CustomerPortalOrdersListQueryParamSubscriptionIDFilter$outboundSchema.parse( customerPortalOrdersListQueryParamSubscriptionIDFilter, ), ); } /** @internal */ export type CustomerPortalOrdersListRequest$Outbound = { product_id?: string | Array | null | undefined; product_billing_type?: string | Array | null | undefined; subscription_id?: string | Array | null | undefined; query?: string | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; }; /** @internal */ export const CustomerPortalOrdersListRequest$outboundSchema: z.ZodMiniType< CustomerPortalOrdersListRequest$Outbound, CustomerPortalOrdersListRequest > = z.pipe( z.object({ productId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), productBillingType: z.optional( z.nullable( smartUnion([ ProductBillingType$outboundSchema, z.array(ProductBillingType$outboundSchema), ]), ), ), subscriptionId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), 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(CustomerOrderSortProperty$outboundSchema)), ), }), z.transform((v) => { return remap$(v, { productId: "product_id", productBillingType: "product_billing_type", subscriptionId: "subscription_id", }); }), ); export function customerPortalOrdersListRequestToJSON( customerPortalOrdersListRequest: CustomerPortalOrdersListRequest, ): string { return JSON.stringify( CustomerPortalOrdersListRequest$outboundSchema.parse( customerPortalOrdersListRequest, ), ); } /** @internal */ export const CustomerPortalOrdersListResponse$inboundSchema: z.ZodMiniType< CustomerPortalOrdersListResponse, unknown > = z.pipe( z.object({ Result: ListResourceCustomerOrder$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function customerPortalOrdersListResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomerPortalOrdersListResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomerPortalOrdersListResponse' from JSON`, ); }