sclass GitterREST { S personalAccessToken; *() {} *(S *personalAccessToken) {} L 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 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)); } CloseableIterableIterator streamMessages(S roomID) { temp tempSetTL(readHttpPageLinewise_extraHeaders, litmap("Authorization", "Bearer " + assertNempty(personalAccessToken))); ret mapI_closeable jsonDecodeMap(readHttpPageLinewise("https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages")); } }