-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
36 lines (29 loc) · 955 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { HTTPClient } from "./http/index.ts";
import { ClientOptions } from "./http/options.ts";
import { ListUsersParameters } from "./http/parameters.ts";
import { CurrentUser, User } from "./models/user.ts";
class Client {
http: HTTPClient;
constructor(public clientOptions: ClientOptions) {
this.http = new HTTPClient(clientOptions.authOptions);
}
async login() {
await this.http.login();
}
async currentUser(): Promise<CurrentUser> {
return await this.http
.getCurrentUser()
.then((user) => new CurrentUser(this.http, user));
}
async getUser(name: string): Promise<User> {
return await this.http
.getUser(name)
.then((user) => new User(this.http, user));
}
async listUsers(parameters?: ListUsersParameters): Promise<User[]> {
return await this.http
.listUsers(parameters)
.then((users) => users.map((user) => new User(this.http, user)));
}
}
export default Client;