-
Notifications
You must be signed in to change notification settings - Fork 87
/
vk.ts
59 lines (44 loc) · 1.16 KB
/
vk.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { inspectable } from 'inspectable';
import { API } from './api';
import { Upload } from './upload';
import { Updates } from './updates';
import { CallbackService } from './utils/callback-service';
import { VKOptions } from './types';
/**
* Main class
*/
export class VK {
public api: API;
public upload: Upload;
public updates: Updates;
public callbackService: CallbackService;
/**
* Constructor
*/
public constructor(options: Partial<VKOptions> & { token: string }) {
this.callbackService = options.callbackService
|| new CallbackService();
this.api = new API({
...options,
callbackService: this.callbackService,
});
this.upload = new Upload({
...options,
api: this.api,
});
this.updates = new Updates({
...options,
api: this.api,
upload: this.upload,
});
}
/**
* Returns custom tag
*/
public get [Symbol.toStringTag](): string {
return this.constructor.name;
}
}
inspectable(VK, {
serialize: ({ api, updates }) => ({ api, updates }),
});