/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 015f86c72852 */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreatecollectionRequest = { /** * The client's preferred locale in rfc5646 format (e.g. `en`, `ja`, `pt-BR`). If omitted, the `Accept-Language` will be used. If not present or not supported, defaults to the closest match or `en`. */ locale?: string | undefined; /** * Collection content plus any additional metadata for the request. */ createCollectionRequest: components.CreateCollectionRequest; }; export type ResponseBody2 = { collection?: components.Collection | undefined; error: components.CollectionError; }; export type ResponseBody1 = { collection: components.Collection; error?: components.CollectionError | undefined; }; /** * OK */ export type CreatecollectionResponse = ResponseBody1 | ResponseBody2; /** @internal */ export type CreatecollectionRequest$Outbound = { locale?: string | undefined; CreateCollectionRequest: components.CreateCollectionRequest$Outbound; }; /** @internal */ export const CreatecollectionRequest$outboundSchema: z.ZodType< CreatecollectionRequest$Outbound, z.ZodTypeDef, CreatecollectionRequest > = z.object({ locale: z.string().optional(), createCollectionRequest: components.CreateCollectionRequest$outboundSchema, }).transform((v) => { return remap$(v, { createCollectionRequest: "CreateCollectionRequest", }); }); export function createcollectionRequestToJSON( createcollectionRequest: CreatecollectionRequest, ): string { return JSON.stringify( CreatecollectionRequest$outboundSchema.parse(createcollectionRequest), ); } /** @internal */ export const ResponseBody2$inboundSchema: z.ZodType< ResponseBody2, z.ZodTypeDef, unknown > = z.object({ collection: components.Collection$inboundSchema.optional(), error: components.CollectionError$inboundSchema, }); export function responseBody2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseBody2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBody2' from JSON`, ); } /** @internal */ export const ResponseBody1$inboundSchema: z.ZodType< ResponseBody1, z.ZodTypeDef, unknown > = z.object({ collection: components.Collection$inboundSchema, error: components.CollectionError$inboundSchema.optional(), }); export function responseBody1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseBody1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBody1' from JSON`, ); } /** @internal */ export const CreatecollectionResponse$inboundSchema: z.ZodType< CreatecollectionResponse, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => ResponseBody1$inboundSchema), z.lazy(() => ResponseBody2$inboundSchema), ]); export function createcollectionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatecollectionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatecollectionResponse' from JSON`, ); }