export type TopicPatchRequest = {name?: string | undefined, description?: string | undefined}; export type PatchApiV2TopicsTopicIdArgs = {'X-Signature'?: string | undefined, 'X-Timestamp'?: number | undefined, topicId: string, body: TopicPatchRequest}; export type PatchApiV2TopicsTopicIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, hmacSignature?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a topic * * PATCH /v2/topics/{topicId} * * Also accepts auth: oauth2ClientCredentials */ export const patchApiV2TopicsTopicId = async (args: PatchApiV2TopicsTopicIdArgs, options?: PatchApiV2TopicsTopicIdOptions) => { const {baseUrl = "https://api.zenzap.co", fetch: fetchFn = fetch, bearerAuth, hmacSignature} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Signature'] != null) headers.set("X-Signature", String(args['X-Signature'])) if (args['X-Timestamp'] != null) headers.set("X-Timestamp", String(args['X-Timestamp'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) if (hmacSignature !== undefined) headers.set("X-Signature", hmacSignature) const url = `${baseUrl.replace(/\/+$/, '')}/v2/topics/${encodeURIComponent(String(args.topicId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };