export type GetApiV1AccountsAccountSidEventsArgs = {accountSid: string, type?: string | undefined, startTime?: string | undefined, endTime?: string | undefined, bucketSid?: string | undefined, environmentSid?: string | undefined, limit?: number | undefined}; export type GetApiV1AccountsAccountSidEventsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns a list of events for an account. * * GET /v1/accounts/{accountSid}/events */ export const getApiV1AccountsAccountSidEvents = async (args: GetApiV1AccountsAccountSidEventsArgs, options?: GetApiV1AccountsAccountSidEventsOptions) => { const {baseUrl = "https://api.apitraffic.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.type != null) query.append("type", String(args.type)) if (args.startTime != null) query.append("startTime", String(args.startTime)) if (args.endTime != null) query.append("endTime", String(args.endTime)) if (args.bucketSid != null) query.append("bucketSid", String(args.bucketSid)) if (args.environmentSid != null) query.append("environmentSid", String(args.environmentSid)) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/accounts/${encodeURIComponent(String(args.accountSid))}/events${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 (await res.json()) as unknown };