Libraryless. Click here for Pure Java version (4011L/27K).
srecord GitterREST(S personalAccessToken) { L<Map> listRooms() { ret jsonDecodeList(loadPageAuthed("https://api.gitter.im/v1/rooms")); } S loadPageAuthed(S url) { temp tempSetTL(loadPage_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken))); ret loadPage(url); } S postPageAuthed(S url, O... params) { temp tempSetTL(doPost_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken))); ret postPage(url, params); } L<Map> listMessages(S roomId, int limit) { ret jsonDecodeList(loadPageAuthed("https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages?limit=" + limit); } Map sendMessage(S roomId, S text) { ret jsonDecodeMap(postPageAuthed("https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages", +text)); } // TODO: restart on close CloseableIterableIterator<Map> streamMessages(S roomId) { temp tempSetTL(readHttpPageLinewise_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken))); ret mapI_notNulls_closeable jsonDecodeMapOrNull(readHttpPageLinewise("https://stream.gitter.im/v1/rooms/" + roomId + "/chatMessages")); } }
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: | 529 / 1054 |
Version history: | 13 change(s) |
Referenced in: | [show references] |