/* * 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Channel endpoint creation request. The structure varies based on the type field. */ export type ChannelEndpointsControllerCreateChannelEndpointRequestBody = | components.CreateSlackChannelEndpointDto | components.CreateSlackUserEndpointDto | components.CreateWebhookEndpointDto | components.CreatePhoneEndpointDto | components.CreateMsTeamsChannelEndpointDto | components.CreateMsTeamsUserEndpointDto; export type ChannelEndpointsControllerCreateChannelEndpointRequest = { /** * A header for idempotency purposes */ idempotencyKey?: string | undefined; /** * Channel endpoint creation request. The structure varies based on the type field. */ requestBody: | components.CreateSlackChannelEndpointDto | components.CreateSlackUserEndpointDto | components.CreateWebhookEndpointDto | components.CreatePhoneEndpointDto | components.CreateMsTeamsChannelEndpointDto | components.CreateMsTeamsUserEndpointDto; }; export type ChannelEndpointsControllerCreateChannelEndpointResponse = { headers: { [k: string]: Array }; result: components.GetChannelEndpointResponseDto; }; /** @internal */ export type ChannelEndpointsControllerCreateChannelEndpointRequestBody$Outbound = | components.CreateSlackChannelEndpointDto$Outbound | components.CreateSlackUserEndpointDto$Outbound | components.CreateWebhookEndpointDto$Outbound | components.CreatePhoneEndpointDto$Outbound | components.CreateMsTeamsChannelEndpointDto$Outbound | components.CreateMsTeamsUserEndpointDto$Outbound; /** @internal */ export const ChannelEndpointsControllerCreateChannelEndpointRequestBody$outboundSchema: z.ZodType< ChannelEndpointsControllerCreateChannelEndpointRequestBody$Outbound, z.ZodTypeDef, ChannelEndpointsControllerCreateChannelEndpointRequestBody > = z.union([ components.CreateSlackChannelEndpointDto$outboundSchema, components.CreateSlackUserEndpointDto$outboundSchema, components.CreateWebhookEndpointDto$outboundSchema, components.CreatePhoneEndpointDto$outboundSchema, components.CreateMsTeamsChannelEndpointDto$outboundSchema, components.CreateMsTeamsUserEndpointDto$outboundSchema, ]); export function channelEndpointsControllerCreateChannelEndpointRequestBodyToJSON( channelEndpointsControllerCreateChannelEndpointRequestBody: ChannelEndpointsControllerCreateChannelEndpointRequestBody, ): string { return JSON.stringify( ChannelEndpointsControllerCreateChannelEndpointRequestBody$outboundSchema .parse(channelEndpointsControllerCreateChannelEndpointRequestBody), ); } /** @internal */ export type ChannelEndpointsControllerCreateChannelEndpointRequest$Outbound = { "idempotency-key"?: string | undefined; RequestBody: | components.CreateSlackChannelEndpointDto$Outbound | components.CreateSlackUserEndpointDto$Outbound | components.CreateWebhookEndpointDto$Outbound | components.CreatePhoneEndpointDto$Outbound | components.CreateMsTeamsChannelEndpointDto$Outbound | components.CreateMsTeamsUserEndpointDto$Outbound; }; /** @internal */ export const ChannelEndpointsControllerCreateChannelEndpointRequest$outboundSchema: z.ZodType< ChannelEndpointsControllerCreateChannelEndpointRequest$Outbound, z.ZodTypeDef, ChannelEndpointsControllerCreateChannelEndpointRequest > = z.object({ idempotencyKey: z.string().optional(), requestBody: z.union([ components.CreateSlackChannelEndpointDto$outboundSchema, components.CreateSlackUserEndpointDto$outboundSchema, components.CreateWebhookEndpointDto$outboundSchema, components.CreatePhoneEndpointDto$outboundSchema, components.CreateMsTeamsChannelEndpointDto$outboundSchema, components.CreateMsTeamsUserEndpointDto$outboundSchema, ]), }).transform((v) => { return remap$(v, { idempotencyKey: "idempotency-key", requestBody: "RequestBody", }); }); export function channelEndpointsControllerCreateChannelEndpointRequestToJSON( channelEndpointsControllerCreateChannelEndpointRequest: ChannelEndpointsControllerCreateChannelEndpointRequest, ): string { return JSON.stringify( ChannelEndpointsControllerCreateChannelEndpointRequest$outboundSchema.parse( channelEndpointsControllerCreateChannelEndpointRequest, ), ); } /** @internal */ export const ChannelEndpointsControllerCreateChannelEndpointResponse$inboundSchema: z.ZodType< ChannelEndpointsControllerCreateChannelEndpointResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())).default({}), Result: components.GetChannelEndpointResponseDto$inboundSchema, }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); export function channelEndpointsControllerCreateChannelEndpointResponseFromJSON( jsonString: string, ): SafeParseResult< ChannelEndpointsControllerCreateChannelEndpointResponse, SDKValidationError > { return safeParse( jsonString, (x) => ChannelEndpointsControllerCreateChannelEndpointResponse$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'ChannelEndpointsControllerCreateChannelEndpointResponse' from JSON`, ); }