export type Device = {device_id: string, device_system: string, device_name: string, device_type: string}; export type CreateApiCustomersActionsSetPushNotificationsArgs = {body: {customer_id: string, device: Device, external_application_id: string, push_token: string}}; export type CreateApiCustomersActionsSetPushNotificationsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set the customer's push notifications * * POST /customers/actions/set-push-notifications * * Also accepts auth: basicAuth */ export const createApiCustomersActionsSetPushNotifications = async (args: CreateApiCustomersActionsSetPushNotificationsArgs, options?: CreateApiCustomersActionsSetPushNotificationsOptions) => { const {baseUrl = "https://sandbox.crmcarecloud.com/webservice/rest-api/enterprise-interface/v1.0", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/customers/actions/set-push-notifications${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 };