/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateWhatsAppAgentConnectorRequestCredentials = { /** * Long-lived Meta system-user access token with whatsapp_business_messaging and whatsapp_business_management permissions. It is encrypted at rest and never returned. */ accessToken: string; /** * Meta app secret used to authenticate webhook payloads. It is encrypted at rest and never returned. */ appSecret: string; }; export type Account = { /** * Meta app ID. It is used with the app secret to verify that the system-user token belongs to this app and has the required WhatsApp permissions. */ appId: string; whatsappBusinessAccountId: string; phoneNumberId: string; }; export const CreateWhatsAppAgentConnectorRequestMode = { Allowlist: "allowlist", } as const; export type CreateWhatsAppAgentConnectorRequestMode = ClosedEnum< typeof CreateWhatsAppAgentConnectorRequestMode >; /** * Exact WhatsApp sender IDs permitted to invoke the agent. These are digit strings without a leading plus sign. */ export type CreateWhatsAppAgentConnectorRequestAccess = { mode: CreateWhatsAppAgentConnectorRequestMode; userIds: Array; }; /** * Beta WhatsApp Cloud API connector configuration. */ export type CreateWhatsAppAgentConnectorRequest = { /** * Beta WhatsApp Cloud API connector with text, image, document, and native thumbs-reaction feedback support. */ provider: "whatsapp"; name?: string | undefined; credentials: CreateWhatsAppAgentConnectorRequestCredentials; account: Account; /** * Exact WhatsApp sender IDs permitted to invoke the agent. These are digit strings without a leading plus sign. */ access: CreateWhatsAppAgentConnectorRequestAccess; }; /** @internal */ export const CreateWhatsAppAgentConnectorRequestCredentials$inboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequestCredentials, z.ZodTypeDef, unknown > = z.object({ access_token: z.string(), app_secret: z.string(), }).transform((v) => { return remap$(v, { "access_token": "accessToken", "app_secret": "appSecret", }); }); /** @internal */ export type CreateWhatsAppAgentConnectorRequestCredentials$Outbound = { access_token: string; app_secret: string; }; /** @internal */ export const CreateWhatsAppAgentConnectorRequestCredentials$outboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequestCredentials$Outbound, z.ZodTypeDef, CreateWhatsAppAgentConnectorRequestCredentials > = z.object({ accessToken: z.string(), appSecret: z.string(), }).transform((v) => { return remap$(v, { accessToken: "access_token", appSecret: "app_secret", }); }); export function createWhatsAppAgentConnectorRequestCredentialsToJSON( createWhatsAppAgentConnectorRequestCredentials: CreateWhatsAppAgentConnectorRequestCredentials, ): string { return JSON.stringify( CreateWhatsAppAgentConnectorRequestCredentials$outboundSchema.parse( createWhatsAppAgentConnectorRequestCredentials, ), ); } export function createWhatsAppAgentConnectorRequestCredentialsFromJSON( jsonString: string, ): SafeParseResult< CreateWhatsAppAgentConnectorRequestCredentials, SDKValidationError > { return safeParse( jsonString, (x) => CreateWhatsAppAgentConnectorRequestCredentials$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateWhatsAppAgentConnectorRequestCredentials' from JSON`, ); } /** @internal */ export const Account$inboundSchema: z.ZodType = z.object({ app_id: z.string(), whatsapp_business_account_id: z.string(), phone_number_id: z.string(), }).transform((v) => { return remap$(v, { "app_id": "appId", "whatsapp_business_account_id": "whatsappBusinessAccountId", "phone_number_id": "phoneNumberId", }); }); /** @internal */ export type Account$Outbound = { app_id: string; whatsapp_business_account_id: string; phone_number_id: string; }; /** @internal */ export const Account$outboundSchema: z.ZodType< Account$Outbound, z.ZodTypeDef, Account > = z.object({ appId: z.string(), whatsappBusinessAccountId: z.string(), phoneNumberId: z.string(), }).transform((v) => { return remap$(v, { appId: "app_id", whatsappBusinessAccountId: "whatsapp_business_account_id", phoneNumberId: "phone_number_id", }); }); export function accountToJSON(account: Account): string { return JSON.stringify(Account$outboundSchema.parse(account)); } export function accountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Account$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Account' from JSON`, ); } /** @internal */ export const CreateWhatsAppAgentConnectorRequestMode$inboundSchema: z.ZodNativeEnum = z .nativeEnum(CreateWhatsAppAgentConnectorRequestMode); /** @internal */ export const CreateWhatsAppAgentConnectorRequestMode$outboundSchema: z.ZodNativeEnum = CreateWhatsAppAgentConnectorRequestMode$inboundSchema; /** @internal */ export const CreateWhatsAppAgentConnectorRequestAccess$inboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequestAccess, z.ZodTypeDef, unknown > = z.object({ mode: CreateWhatsAppAgentConnectorRequestMode$inboundSchema, user_ids: z.array(z.string()), }).transform((v) => { return remap$(v, { "user_ids": "userIds", }); }); /** @internal */ export type CreateWhatsAppAgentConnectorRequestAccess$Outbound = { mode: string; user_ids: Array; }; /** @internal */ export const CreateWhatsAppAgentConnectorRequestAccess$outboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequestAccess$Outbound, z.ZodTypeDef, CreateWhatsAppAgentConnectorRequestAccess > = z.object({ mode: CreateWhatsAppAgentConnectorRequestMode$outboundSchema, userIds: z.array(z.string()), }).transform((v) => { return remap$(v, { userIds: "user_ids", }); }); export function createWhatsAppAgentConnectorRequestAccessToJSON( createWhatsAppAgentConnectorRequestAccess: CreateWhatsAppAgentConnectorRequestAccess, ): string { return JSON.stringify( CreateWhatsAppAgentConnectorRequestAccess$outboundSchema.parse( createWhatsAppAgentConnectorRequestAccess, ), ); } export function createWhatsAppAgentConnectorRequestAccessFromJSON( jsonString: string, ): SafeParseResult< CreateWhatsAppAgentConnectorRequestAccess, SDKValidationError > { return safeParse( jsonString, (x) => CreateWhatsAppAgentConnectorRequestAccess$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CreateWhatsAppAgentConnectorRequestAccess' from JSON`, ); } /** @internal */ export const CreateWhatsAppAgentConnectorRequest$inboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequest, z.ZodTypeDef, unknown > = z.object({ provider: z.literal("whatsapp"), name: z.string().optional(), credentials: z.lazy(() => CreateWhatsAppAgentConnectorRequestCredentials$inboundSchema ), account: z.lazy(() => Account$inboundSchema), access: z.lazy(() => CreateWhatsAppAgentConnectorRequestAccess$inboundSchema), }); /** @internal */ export type CreateWhatsAppAgentConnectorRequest$Outbound = { provider: "whatsapp"; name?: string | undefined; credentials: CreateWhatsAppAgentConnectorRequestCredentials$Outbound; account: Account$Outbound; access: CreateWhatsAppAgentConnectorRequestAccess$Outbound; }; /** @internal */ export const CreateWhatsAppAgentConnectorRequest$outboundSchema: z.ZodType< CreateWhatsAppAgentConnectorRequest$Outbound, z.ZodTypeDef, CreateWhatsAppAgentConnectorRequest > = z.object({ provider: z.literal("whatsapp"), name: z.string().optional(), credentials: z.lazy(() => CreateWhatsAppAgentConnectorRequestCredentials$outboundSchema ), account: z.lazy(() => Account$outboundSchema), access: z.lazy(() => CreateWhatsAppAgentConnectorRequestAccess$outboundSchema ), }); export function createWhatsAppAgentConnectorRequestToJSON( createWhatsAppAgentConnectorRequest: CreateWhatsAppAgentConnectorRequest, ): string { return JSON.stringify( CreateWhatsAppAgentConnectorRequest$outboundSchema.parse( createWhatsAppAgentConnectorRequest, ), ); } export function createWhatsAppAgentConnectorRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateWhatsAppAgentConnectorRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateWhatsAppAgentConnectorRequest' from JSON`, ); }