export type SubscriptionTopicStatus = 'OPTED_OUT' | 'OPTED_IN' | 'REQUIRED'; export type ChannelClassification = 'direct_message' | 'email' | 'push' | 'sms' | 'webhook' | 'inbox'; export type SubscriptionTopicNew = {status: SubscriptionTopicStatus, has_custom_routing?: (boolean | null) | undefined, custom_routing?: (Array | null) | undefined}; export type UpdateApiTenantsTenantIdDefaultPreferencesItemsTopicIdArgs = {tenant_id: string, topic_id: string, body: SubscriptionTopicNew}; export type UpdateApiTenantsTenantIdDefaultPreferencesItemsTopicIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or Replace Default Preferences For Topic * * PUT /tenants/{tenant_id}/default_preferences/items/{topic_id} */ export const updateApiTenantsTenantIdDefaultPreferencesItemsTopicId = async (args: UpdateApiTenantsTenantIdDefaultPreferencesItemsTopicIdArgs, options?: UpdateApiTenantsTenantIdDefaultPreferencesItemsTopicIdOptions) => { const {baseUrl = "https://api.courier.com", 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(/\/+$/, '')}/tenants/${encodeURIComponent(String(args.tenant_id))}/default_preferences/items/${encodeURIComponent(String(args.topic_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };