export type GetApiPipelineAuditEventArgs = {from: string, to: string, page_size: number, page_index: number}; export type GetApiPipelineAuditEventOptions = {baseUrl?: string | undefined, PipelineServiceKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch audit events * * GET /pipeline/audit-event */ export const getApiPipelineAuditEvent = async (args: GetApiPipelineAuditEventArgs, options?: GetApiPipelineAuditEventOptions) => { const {baseUrl = "https://api.mezmo.com/v3", fetch: fetchFn = fetch, PipelineServiceKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.page_size != null) query.append("page_size", String(args.page_size)) if (args.page_index != null) query.append("page_index", String(args.page_index)) if (PipelineServiceKey !== undefined) headers.set("Authorization", PipelineServiceKey) const url = `${baseUrl.replace(/\/+$/, '')}/pipeline/audit-event${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };