export type AlertEnabled = boolean; export type AlertPropertyId = number; export type AlertPropertyValue = string; export type StoreAlertProperty = {propertyId: AlertPropertyId, propertyValue: AlertPropertyValue}; export type StoreAlertMail = string; export type SaveStoreAlertRequest = {enabled: AlertEnabled, properties?: Array | undefined, storeAlertMails?: Array | undefined}; export type SaveStoreAlertsRequest = {[key: string]: SaveStoreAlertRequest}; export type CreateApiV2UserCustomerStoresStoreIdAlertsArgs = {storeId: unknown, body: SaveStoreAlertsRequest}; export type CreateApiV2UserCustomerStoresStoreIdAlertsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save store alerts * * POST /v2/user/customer/stores/{storeId}/alerts */ export const createApiV2UserCustomerStoresStoreIdAlerts = async (args: CreateApiV2UserCustomerStoresStoreIdAlertsArgs, options?: CreateApiV2UserCustomerStoresStoreIdAlertsOptions) => { const {baseUrl = "https://api.beezup.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/customer/stores/${encodeURIComponent(String(args.storeId))}/alerts${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 };