export type CreateApiPartnerAccountApiAppLinkArgs = {Authorization?: string | undefined, body: {apiKey?: string | undefined, appName?: string | undefined}}; export type CreateApiPartnerAccountApiAppLinkOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Link App with Partner * * POST /partner/account/api/appLink */ export const createApiPartnerAccountApiAppLink = async (args: CreateApiPartnerAccountApiAppLinkArgs, options?: CreateApiPartnerAccountApiAppLinkOptions) => { 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/account/api/appLink${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 };