/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Message returned with supporting information from a request. In some cases this can be an error message, * * @remarks * for example a timeout from a carrier. If available, the origin of the message is displayed in `source`. */ export type ResponseMessage = { /** * Origin of message */ source?: string | undefined; /** * Classification of message */ code?: string | undefined; /** * Message content */ text?: string | undefined; }; /** @internal */ export const ResponseMessage$inboundSchema: z.ZodMiniType< ResponseMessage, unknown > = z.object({ source: z.optional(z.string()), code: z.optional(z.string()), text: z.optional(z.string()), }); /** @internal */ export type ResponseMessage$Outbound = { source?: string | undefined; code?: string | undefined; text?: string | undefined; }; /** @internal */ export const ResponseMessage$outboundSchema: z.ZodMiniType< ResponseMessage$Outbound, ResponseMessage > = z.object({ source: z.optional(z.string()), code: z.optional(z.string()), text: z.optional(z.string()), }); export function responseMessageToJSON( responseMessage: ResponseMessage, ): string { return JSON.stringify(ResponseMessage$outboundSchema.parse(responseMessage)); } export function responseMessageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ResponseMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseMessage' from JSON`, ); }