/* * 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"; import { CreateSessionStatus, CreateSessionStatus$inboundSchema, } from "./createsessionstatus.js"; /** * The session data received from the payment service. */ export type CreateSession = { /** * Always `payment-service-session`. */ type: "payment-service-session"; status: CreateSessionStatus; /** * A generic error code that may be returned when the session could not be generated. */ code?: string | null | undefined; /** * The HTTP status code received from the payment service. */ statusCode?: number | null | undefined; /** * The JSON response body received from the payment service. */ responseBody?: { [k: string]: any } | null | undefined; }; /** @internal */ export const CreateSession$inboundSchema: z.ZodType< CreateSession, z.ZodTypeDef, unknown > = z.object({ type: z.literal("payment-service-session").default("payment-service-session"), status: CreateSessionStatus$inboundSchema, code: z.nullable(z.string()).optional(), status_code: z.nullable(z.number().int()).optional(), response_body: z.nullable(z.record(z.any())).optional(), }).transform((v) => { return remap$(v, { "status_code": "statusCode", "response_body": "responseBody", }); }); export function createSessionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSession$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSession' from JSON`, ); }