/* * 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 { BenefitGrantSortProperty, BenefitGrantSortProperty$outboundSchema, } from "../components/benefitgrantsortproperty.js"; import { ListResourceBenefitGrant, ListResourceBenefitGrant$inboundSchema, } from "../components/listresourcebenefitgrant.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Filter by organization ID. */ export type BenefitGrantsListQueryParamOrganizationIDFilter = | string | Array; /** * Filter by customer ID. */ export type BenefitGrantsListQueryParamCustomerIDFilter = | string | Array; /** * Filter by customer external ID. */ export type QueryParamExternalCustomerIDFilter = string | Array; export type BenefitGrantsListRequest = { /** * Filter by organization ID. */ organizationId?: 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 granted status. If `true`, only granted benefits will be returned. If `false`, only revoked benefits will be returned. */ isGranted?: 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 BenefitGrantsListResponse = { result: ListResourceBenefitGrant; }; /** @internal */ export type BenefitGrantsListQueryParamOrganizationIDFilter$Outbound = | string | Array; /** @internal */ export const BenefitGrantsListQueryParamOrganizationIDFilter$outboundSchema: z.ZodMiniType< BenefitGrantsListQueryParamOrganizationIDFilter$Outbound, BenefitGrantsListQueryParamOrganizationIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function benefitGrantsListQueryParamOrganizationIDFilterToJSON( benefitGrantsListQueryParamOrganizationIDFilter: BenefitGrantsListQueryParamOrganizationIDFilter, ): string { return JSON.stringify( BenefitGrantsListQueryParamOrganizationIDFilter$outboundSchema.parse( benefitGrantsListQueryParamOrganizationIDFilter, ), ); } /** @internal */ export type BenefitGrantsListQueryParamCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const BenefitGrantsListQueryParamCustomerIDFilter$outboundSchema: z.ZodMiniType< BenefitGrantsListQueryParamCustomerIDFilter$Outbound, BenefitGrantsListQueryParamCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function benefitGrantsListQueryParamCustomerIDFilterToJSON( benefitGrantsListQueryParamCustomerIDFilter: BenefitGrantsListQueryParamCustomerIDFilter, ): string { return JSON.stringify( BenefitGrantsListQueryParamCustomerIDFilter$outboundSchema.parse( benefitGrantsListQueryParamCustomerIDFilter, ), ); } /** @internal */ export type QueryParamExternalCustomerIDFilter$Outbound = | string | Array; /** @internal */ export const QueryParamExternalCustomerIDFilter$outboundSchema: z.ZodMiniType< QueryParamExternalCustomerIDFilter$Outbound, QueryParamExternalCustomerIDFilter > = smartUnion([z.string(), z.array(z.string())]); export function queryParamExternalCustomerIDFilterToJSON( queryParamExternalCustomerIDFilter: QueryParamExternalCustomerIDFilter, ): string { return JSON.stringify( QueryParamExternalCustomerIDFilter$outboundSchema.parse( queryParamExternalCustomerIDFilter, ), ); } /** @internal */ export type BenefitGrantsListRequest$Outbound = { organization_id?: string | Array | null | undefined; customer_id?: string | Array | null | undefined; external_customer_id?: string | Array | null | undefined; is_granted?: boolean | null | undefined; page: number; limit: number; sorting?: Array | null | undefined; }; /** @internal */ export const BenefitGrantsListRequest$outboundSchema: z.ZodMiniType< BenefitGrantsListRequest$Outbound, BenefitGrantsListRequest > = z.pipe( z.object({ organizationId: 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())])), ), isGranted: 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(BenefitGrantSortProperty$outboundSchema)), ), }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", customerId: "customer_id", externalCustomerId: "external_customer_id", isGranted: "is_granted", }); }), ); export function benefitGrantsListRequestToJSON( benefitGrantsListRequest: BenefitGrantsListRequest, ): string { return JSON.stringify( BenefitGrantsListRequest$outboundSchema.parse(benefitGrantsListRequest), ); } /** @internal */ export const BenefitGrantsListResponse$inboundSchema: z.ZodMiniType< BenefitGrantsListResponse, unknown > = z.pipe( z.object({ Result: ListResourceBenefitGrant$inboundSchema, }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function benefitGrantsListResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BenefitGrantsListResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BenefitGrantsListResponse' from JSON`, ); }