Libraryless. Click here for Pure Java version (4011L/27K).
1 | srecord GitterREST(S personalAccessToken) {
|
2 | L<Map> listRooms() {
|
3 | ret jsonDecodeList(loadPageAuthed("https://api.gitter.im/v1/rooms"));
|
4 | } |
5 | |
6 | S loadPageAuthed(S url) {
|
7 | temp tempSetTL(loadPage_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken)));
|
8 | ret loadPage(url); |
9 | } |
10 | |
11 | S postPageAuthed(S url, O... params) {
|
12 | temp tempSetTL(doPost_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken)));
|
13 | ret postPage(url, params); |
14 | } |
15 | |
16 | L<Map> listMessages(S roomId, int limit) {
|
17 | ret jsonDecodeList(loadPageAuthed("https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages?limit=" + limit);
|
18 | } |
19 | |
20 | Map sendMessage(S roomId, S text) {
|
21 | ret jsonDecodeMap(postPageAuthed("https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages", +text));
|
22 | } |
23 | |
24 | // TODO: restart on close |
25 | CloseableIterableIterator<Map> streamMessages(S roomId) {
|
26 | temp tempSetTL(readHttpPageLinewise_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken)));
|
27 | ret mapI_notNulls_closeable jsonDecodeMapOrNull(readHttpPageLinewise("https://stream.gitter.im/v1/rooms/" + roomId + "/chatMessages"));
|
28 | } |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1023546 |
| Snippet name: | GitterREST |
| Eternal ID of this version: | #1023546/14 |
| Text MD5: | 9a162405a3768509fc2bbb161b434a02 |
| Transpilation MD5: | 437cd3ed5ed516c2b2345eabde5ffbdc |
| Author: | stefan |
| Category: | javax / networking |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-06-28 12:20:58 |
| Source code size: | 1224 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 915 / 1562 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |