import { DefaultClient, AKResponse, QueryArguments } from "./Client"; let _globalMePromise: Promise; export class User { pk: number; username: string; name: string; is_superuser: boolean; email: boolean; avatar: string; is_active: boolean; last_login: number; constructor() { throw Error(); } static get(pk: string): Promise { return DefaultClient.fetch(["core", "users", pk]); } static list(filter?: QueryArguments): Promise> { return DefaultClient.fetch>(["core", "users"], filter); } static adminUrl(rest: string): string { return `/administration/users/${rest}`; } static me(): Promise { if (!_globalMePromise) { _globalMePromise = DefaultClient.fetch(["core", "users", "me"]); } return _globalMePromise; } static count(): Promise { return DefaultClient.fetch>(["core", "users"], { "page_size": 1 }).then(r => { return r.pagination.count; }); } }