export type SendCustomMessage = {data: {[key: string]: string}, name: string}; export type CreateApiApiV1OrganizationsOrganizationIdMessagingEnqueueCustomMessageArgs = {organizationId: string, body: SendCustomMessage}; export type CreateApiApiV1OrganizationsOrganizationIdMessagingEnqueueCustomMessageOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Enqueue a custom message * * POST /api/v1/organizations/{organizationId}/messaging/enqueueCustomMessage */ export const createApiApiV1OrganizationsOrganizationIdMessagingEnqueueCustomMessage = async (args: CreateApiApiV1OrganizationsOrganizationIdMessagingEnqueueCustomMessageArgs, options: CreateApiApiV1OrganizationsOrganizationIdMessagingEnqueueCustomMessageOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/organizations/${encodeURIComponent(String(args.organizationId))}/messaging/enqueueCustomMessage${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };