/
conversationService.ts
74 lines (64 loc) · 1.96 KB
/
conversationService.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import fetch, { Headers } from 'node-fetch';
export const headers = new Headers({
'Content-Accept': 'application/json'
});
export class ConversationService {
public static addUser(serviceUrl: string, conversationId: string, name?: string, id?: string) {
const url = `${serviceUrl}/emulator/${conversationId}/users`;
return fetch(url, {
headers,
method: 'POST',
body: JSON.stringify([{ name, id }])
});
}
public static removeUser(serviceUrl: string, conversationId: string, id: string) {
const url = `${serviceUrl}/emulator/${conversationId}/users`;
return fetch(url, {
headers,
method: 'DELETE',
body: JSON.stringify([{ id }])
});
}
public static removeRandomUser(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/users`;
return fetch(url, {
headers,
method: 'DELETE',
});
}
public static botContactAdded(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/contacts`;
return fetch(url, {
headers,
method: 'POST'
});
}
public static botContactRemoved(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/contacts`;
return fetch(url, {
headers,
method: 'DELETE'
});
}
public static typing(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/typing`;
return fetch(url, {
headers,
method: 'POST'
});
}
public static ping(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/ping`;
return fetch(url, {
headers,
method: 'POST'
});
}
public static deleteUserData(serviceUrl: string, conversationId: string) {
const url = `${serviceUrl}/emulator/${conversationId}/userdata`;
return fetch(url, {
headers,
method: 'DELETE'
});
}
}