export type WebhookProfileCreateRequest = {eventTypes?: (Array<'TRANSACTION_CRYPTO_PENDING' | 'TRANSACTION_CRYPTO_FAILED' | 'TRANSACTION_CRYPTO_TRANSFERRING' | 'TRANSACTION_CRYPTO_COMPLETE' | 'TRANSACTION_FIAT_CREATED' | 'TRANSACTION_FIAT_UPDATED' | 'BANK_LINKING_CONNECTION_COMPLETED' | 'BANK_LINKING_CONNECTION_DELETED' | 'BANK_LINKING_CONNECTION_STATUS_CHANGE' | 'BANK_LINKING_ACCOUNTS_ADDED' | 'BANK_LINKING_ACCOUNTS_UPDATING' | 'BANK_LINKING_ACCOUNTS_UPDATED' | 'BANK_LINKING_ACCOUNTS_REMOVED' | 'BANK_LINKING_TRANSACTIONS_AGGREGATED' | 'BANK_LINKING_HISTORICAL_TRANSACTIONS_AGGREGATED' | 'BANK_LINKING_NEW_ACCOUNTS_AVAILABLE' | 'CUSTOMER_KYC_STATUS_CHANGE' | 'TEST' | 'WEBHOOK_TEST'>) | undefined, eventVersion?: string | undefined, name: string, url: string}; export type CreateApiNotificationsWebhooksArgs = {body: WebhookProfileCreateRequest}; export type CreateApiNotificationsWebhooksOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new webhook profile * * POST /notifications/webhooks */ export const createApiNotificationsWebhooks = async (args: CreateApiNotificationsWebhooksArgs, options?: CreateApiNotificationsWebhooksOptions) => { const {baseUrl = "https://api-sb.meld.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/notifications/webhooks${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 res.blob() };