/* * 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 { ListResourceRefund, ListResourceRefund$inboundSchema, } from "../components/listresourcerefund.js"; import { RefundSortProperty, RefundSortProperty$outboundSchema, } from "../components/refundsortproperty.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by refund ID. */ export type RefundIDFilter = string | Array; /** * Filter by organization ID. */ export type RefundsListQueryParamOrganizationIDFilter = string | Array; /** * Filter by order ID. */ export type OrderIDFilter = string | Array; /** * Filter by subscription ID. */ export type QueryParamSubscriptionIDFilter = string | Array; /** * Filter by customer ID. */ export type RefundsListQueryParamCustomerIDFilter = string | Array; /** * Filter by customer external ID. */ export type RefundsListQueryParamExternalCustomerIDFilter = | string | Array; export type RefundsListRequest = { /** * Filter by refund ID. */ id?: string | Array | null | undefined; /** * Filter by organization ID. */ organizationId?: string | Array | null | undefined; /** * Filter by order ID. */ orderId?: string | Array | null | undefined; /** * Filter by subscription ID. */ subscriptionId?: 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 `succeeded`. */ succeeded?: boolean | 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 RefundsListResponse = { result: ListResourceRefund; }; /** @internal */ export type RefundIDFilter$Outbound = string | Array; /** @internal */ export const RefundIDFilter$outboundSchema: z.ZodMiniType< RefundIDFilter$Outbound, RefundIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function refundIDFilterToJSON(refundIDFilter: RefundIDFilter): string { return JSON.stringify(RefundIDFilter$outboundSchema.parse(refundIDFilter)); } /** @internal */ export type RefundsListQueryParamOrganizationIDFilter$Outbound = | string | Array; /** @internal */ export const RefundsListQueryParamOrganizationIDFilter$outboundSchema: z.ZodMiniType< RefundsListQueryParamOrganizationIDFilter$Outbound, RefundsListQueryParamOrganizationIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function refundsListQueryParamOrganizationIDFilterToJSON( refundsListQueryParamOrganizationIDFilter: RefundsListQueryParamOrganizationIDFilter, ): string { return JSON.stringify( RefundsListQueryParamOrganizationIDFilter$outboundSchema.parse( refundsListQueryParamOrganizationIDFilter, ), ); } /** @internal */ export type OrderIDFilter$Outbound = string | Array; /** @internal */ export const OrderIDFilter$outboundSchema: z.ZodMiniType< OrderIDFilter$Outbound, OrderIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function orderIDFilterToJSON(orderIDFilter: OrderIDFilter): string { return JSON.stringify(OrderIDFilter$outboundSchema.parse(orderIDFilter)); } /** @internal */ export type QueryParamSubscriptionIDFilter$Outbound = string | Array; /** @internal */ export const QueryParamSubscriptionIDFilter$outboundSchema: z.ZodMiniType< QueryParamSubscriptionIDFilter$Outbound, QueryParamSubscriptionIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function queryParamSubscriptionIDFilterToJSON( queryParamSubscriptionIDFilter: QueryParamSubscriptionIDFilter, ): string { return JSON.stringify( QueryParamSubscriptionIDFilter$outboundSchema.parse( queryParamSubscriptionIDFilter, ), ); } /** @internal */ export type RefundsListQueryParamCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const RefundsListQueryParamCustomerIDFilter$outboundSchema: z.ZodMiniType< RefundsListQueryParamCustomerIDFilter$Outbound, RefundsListQueryParamCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function refundsListQueryParamCustomerIDFilterToJSON( refundsListQueryParamCustomerIDFilter: RefundsListQueryParamCustomerIDFilter, ): string { return JSON.stringify( RefundsListQueryParamCustomerIDFilter$outboundSchema.parse( refundsListQueryParamCustomerIDFilter, ), ); } /** @internal */ export type RefundsListQueryParamExternalCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const RefundsListQueryParamExternalCustomerIDFilter$outboundSchema: z.ZodMiniType< RefundsListQueryParamExternalCustomerIDFilter$Outbound, RefundsListQueryParamExternalCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function refundsListQueryParamExternalCustomerIDFilterToJSON( refundsListQueryParamExternalCustomerIDFilter: RefundsListQueryParamExternalCustomerIDFilter, ): string { return JSON.stringify( RefundsListQueryParamExternalCustomerIDFilter$outboundSchema.parse( refundsListQueryParamExternalCustomerIDFilter, ), ); } /** @internal */ export type RefundsListRequest$Outbound = { id?: string | Array | null | undefined; organization_id?: string | Array | null | undefined; order_id?: string | Array | null | undefined; subscription_id?: string | Array | null | undefined; customer_id?: string | Array | null | undefined; external_customer_id?: string | Array | null | undefined; succeeded?: boolean | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; }; /** @internal */ export const RefundsListRequest$outboundSchema: z.ZodMiniType< RefundsListRequest$Outbound, RefundsListRequest > = z.pipe( z.object({ id: z.optional(z.nullable(smartUnion([z.string(), z.array(z.string())]))), organizationId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), orderId: z.optional( z.nullable(smartUnion([z.string(), z.array(z.string())])), ), subscriptionId: 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())])), ), succeeded: z.optional(z.nullable(z.boolean())), page: z._default(z.int(), 1), limit: z._default(z.int(), 10), sorting: z.optional(z.nullable(z.array(RefundSortProperty$outboundSchema))), }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", orderId: "order_id", subscriptionId: "subscription_id", customerId: "customer_id", externalCustomerId: "external_customer_id", }); }), ); export function refundsListRequestToJSON( refundsListRequest: RefundsListRequest, ): string { return JSON.stringify( RefundsListRequest$outboundSchema.parse(refundsListRequest), ); } /** @internal */ export const RefundsListResponse$inboundSchema: z.ZodMiniType< RefundsListResponse, unknown > = z.pipe( z.object({ Result: ListResourceRefund$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function refundsListResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RefundsListResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RefundsListResponse' from JSON`, ); }