-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdMemberAppend.ts
More file actions
44 lines (37 loc) · 1.14 KB
/
cmdMemberAppend.ts
File metadata and controls
44 lines (37 loc) · 1.14 KB
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
import {Admin, MemberAppendCommand} from "../../api/admin";
import {Callback} from "../../model/models";
import Axios from "axios";
class MemberAppendCommandImpl implements MemberAppendCommand {
private admin: Admin;
private members: { members: string[] };
constructor(admin: Admin, members: string[]) {
this.admin = admin;
this.members = {
members,
};
}
public intoRoom(roomid: string, callback?: Callback<void>): Admin {
return this.invokeAppend(`/rooms/${roomid}`, callback);
}
public intoGroup(groupid: string, callback?: Callback<void>): Admin {
return this.invokeAppend(`/groups/${groupid}`, callback);
}
private invokeAppend(path: string, callback?: Callback<void>): Admin {
const url = `${this.admin.options().server}${path}/members`;
Axios.post(url, JSON.stringify(this.members), {headers: this.admin.options().headers})
.then((ignore) => {
if (callback) {
callback(null, null);
}
})
.catch((e) => {
if (callback) {
callback(e);
}
});
return this.admin;
}
}
export {
MemberAppendCommandImpl,
};