export type CreateApiV2MessagesMessageIdReadArgs = {'X-Signature'?: string | undefined, 'X-Timestamp'?: number | undefined, messageId: string}; export type CreateApiV2MessagesMessageIdReadOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, hmacSignature?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark a message as read * * POST /v2/messages/{messageId}/read * * Also accepts auth: oauth2ClientCredentials */ export const createApiV2MessagesMessageIdRead = async (args: CreateApiV2MessagesMessageIdReadArgs, options?: CreateApiV2MessagesMessageIdReadOptions) => { const {baseUrl = "https://api.zenzap.co", fetch: fetchFn = fetch, bearerAuth, hmacSignature} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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/messages/${encodeURIComponent(String(args.messageId))}/read${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };