export type IncomingWebhook = {name: string, function_source: string, respond_result: boolean, options?: ({secret?: string | undefined, secretAsQueryParam?: boolean | undefined}) | undefined}; export type UpdateApiGroupsGroupIdAppsAppIdServicesServiceIdIncomingWebhooksIncomingWebhookIdArgs = {body: IncomingWebhook}; export type UpdateApiGroupsGroupIdAppsAppIdServicesServiceIdIncomingWebhooksIncomingWebhookIdOptions = {baseUrl?: string | undefined, tokenAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a webhook * * PUT /groups/{groupId}/apps/{appId}/services/{serviceId}/incoming_webhooks/{incomingWebhookId} */ export const updateApiGroupsGroupIdAppsAppIdServicesServiceIdIncomingWebhooksIncomingWebhookId = async (args: UpdateApiGroupsGroupIdAppsAppIdServicesServiceIdIncomingWebhooksIncomingWebhookIdArgs, options?: UpdateApiGroupsGroupIdAppsAppIdServicesServiceIdIncomingWebhooksIncomingWebhookIdOptions) => { const {baseUrl = "https://services.cloud.mongodb.com/api/admin/v3.0", fetch: fetchFn = fetch, tokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (tokenAuth !== undefined) headers.set('authorization', `Bearer ${tokenAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/groups/${encodeURIComponent(String(args.groupId))}/apps/${encodeURIComponent(String(args.appId))}/services/${encodeURIComponent(String(args.serviceId))}/incoming_webhooks/${encodeURIComponent(String(args.incomingWebhookId))}${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 };