1 |
|
2 |
|
3 | export type Config = {
|
4 | mainframe_url: string,
|
5 | secret: string,
|
6 | server_port: number,
|
7 | server_url: string,
|
8 | username: string,
|
9 | }
|
10 |
|
11 | export type ClientContext = {
|
12 | user: Object,
|
13 | conversation?: ?Object,
|
14 | organization?: ?Object,
|
15 | subscription_token?: string,
|
16 | }
|
17 |
|
18 | export type PostPayload = {
|
19 | user_id: string,
|
20 | data: Object,
|
21 | context: ClientContext,
|
22 | }
|
23 |
|
24 | export type BotContext = {
|
25 | config: Config,
|
26 | callMainframe: (endpoint: string, data?: Object) => Promise<Object>,
|
27 | sendEvent: (payload: {
|
28 | conversation_id: string,
|
29 | message?: string,
|
30 | data?: Object,
|
31 | }) => Promise<Object>,
|
32 | }
|
33 |
|
34 | export type BotResponse = {
|
35 | success: boolean,
|
36 | message?: string,
|
37 | data?: Object,
|
38 | }
|
39 |
|
40 | export type Handlers = {
|
41 | enable?: (payload: { user_id: string }) => void,
|
42 | disable?: (payload: { user_id: string }) => void,
|
43 | conversation_added?: (payload: {
|
44 | user_id: string,
|
45 | conversation_id: string,
|
46 | }) => void,
|
47 | conversation_removed?: (payload: {
|
48 | user_id: string,
|
49 | conversation_id: string,
|
50 | }) => void,
|
51 | edit_subscription?: (payload: {
|
52 | user_id: string,
|
53 | conversation_id: string,
|
54 | subscription_id: string,
|
55 | }) => void,
|
56 | delete_subscription?: (payload: { subscription_id: string }) => void,
|
57 | post?: (payload: PostRequest) => Promise<BotResponse>,
|
58 | }
|