/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetPublicImageRequest = { ifNoneMatch?: string | undefined; publicID: string; /** * Optional parameter to request a resized version of the image (WxH). * * @remarks * * If either dimension is 0, the image will be scaled proportionally based on * the non-zero dimension. Dimensions are capped at 2048 pixels. A default size * of 400x400 will be used if this parameter is omitted. */ size?: string | undefined; }; export type GetPublicImageResponseResult = | ReadableStream | ReadableStream | ReadableStream; export type GetPublicImageResponse = { headers: { [k: string]: Array }; result: | ReadableStream | ReadableStream | ReadableStream; }; /** @internal */ export const GetPublicImageRequest$inboundSchema: z.ZodType< GetPublicImageRequest, z.ZodTypeDef, unknown > = z.object({ "if-none-match": z.string().optional(), publicID: z.string(), size: z.string().default("400x400"), }).transform((v) => { return remap$(v, { "if-none-match": "ifNoneMatch", }); }); /** @internal */ export type GetPublicImageRequest$Outbound = { "if-none-match"?: string | undefined; publicID: string; size: string; }; /** @internal */ export const GetPublicImageRequest$outboundSchema: z.ZodType< GetPublicImageRequest$Outbound, z.ZodTypeDef, GetPublicImageRequest > = z.object({ ifNoneMatch: z.string().optional(), publicID: z.string(), size: z.string().default("400x400"), }).transform((v) => { return remap$(v, { ifNoneMatch: "if-none-match", }); }); export function getPublicImageRequestToJSON( getPublicImageRequest: GetPublicImageRequest, ): string { return JSON.stringify( GetPublicImageRequest$outboundSchema.parse(getPublicImageRequest), ); } export function getPublicImageRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicImageRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicImageRequest' from JSON`, ); } /** @internal */ export const GetPublicImageResponseResult$inboundSchema: z.ZodType< GetPublicImageResponseResult, z.ZodTypeDef, unknown > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** @internal */ export type GetPublicImageResponseResult$Outbound = | ReadableStream | ReadableStream | ReadableStream; /** @internal */ export const GetPublicImageResponseResult$outboundSchema: z.ZodType< GetPublicImageResponseResult$Outbound, z.ZodTypeDef, GetPublicImageResponseResult > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); export function getPublicImageResponseResultToJSON( getPublicImageResponseResult: GetPublicImageResponseResult, ): string { return JSON.stringify( GetPublicImageResponseResult$outboundSchema.parse( getPublicImageResponseResult, ), ); } export function getPublicImageResponseResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicImageResponseResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicImageResponseResult' from JSON`, ); } /** @internal */ export const GetPublicImageResponse$inboundSchema: z.ZodType< GetPublicImageResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())).default({}), Result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); /** @internal */ export type GetPublicImageResponse$Outbound = { Headers: { [k: string]: Array }; Result: | ReadableStream | ReadableStream | ReadableStream; }; /** @internal */ export const GetPublicImageResponse$outboundSchema: z.ZodType< GetPublicImageResponse$Outbound, z.ZodTypeDef, GetPublicImageResponse > = z.object({ headers: z.record(z.array(z.string())), result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { headers: "Headers", result: "Result", }); }); export function getPublicImageResponseToJSON( getPublicImageResponse: GetPublicImageResponse, ): string { return JSON.stringify( GetPublicImageResponse$outboundSchema.parse(getPublicImageResponse), ); } export function getPublicImageResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetPublicImageResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetPublicImageResponse' from JSON`, ); }