export type CreateApiPartnerAppAppIdTemplateMsgArgs = {Authorization?: string | undefined, appId: string, body: {source?: number | undefined, sandbox?: boolean | undefined, destination?: number | undefined, template?: string | undefined, 'src.name'?: string | undefined, message?: number | undefined}}; export type CreateApiPartnerAppAppIdTemplateMsgOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * App | Send msg With Template ID * * POST /partner/app/{appId}/template/msg */ export const createApiPartnerAppAppIdTemplateMsg = async (args: CreateApiPartnerAppAppIdTemplateMsgArgs, options?: CreateApiPartnerAppAppIdTemplateMsgOptions) => { const {baseUrl = "https://partner.gupshup.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/partner/app/${encodeURIComponent(String(args.appId))}/template/msg${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };