import { DefaultClient, AKResponse, QueryArguments } from "./Client"; export interface EventUser { pk: number; email?: string; username: string; on_behalf_of?: EventUser; } export interface EventContext { [key: string]: EventContext | string | number | string[]; } export class Event { pk: string; user: EventUser; action: string; app: string; context: EventContext; client_ip: string; created: string; constructor() { throw Error(); } static get(pk: string): Promise { return DefaultClient.fetch(["events", "events", pk]); } static list(filter?: QueryArguments): Promise> { return DefaultClient.fetch>(["events", "events"], filter); } // events/events/top_per_user/?filter_action=authorize_application static topForUser(action: string): Promise { return DefaultClient.fetch(["events", "events", "top_per_user"], { "filter_action": action, }); } } export interface TopNEvent { application: { [key: string]: string}; counted_events: number; unique_users: number; }