Last active
March 8, 2017 06:32
-
-
Save rebolek/ce2aa5aa00276e836029f8d0fcf7f7a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: "Gitter API" | |
Author: "Boleslav Březovský" | |
File: %gitter-api.red | |
Rights: "Copyright (C) 2016 Boleslav Březovský. All rights reserved." | |
License: { | |
Distributed under the Boost Software License, Version 1.0. | |
} | |
Date: "23-10-2016" | |
Note: { | |
} | |
] | |
token: #1234 | |
bearer: function [token] [ | |
rejoin ["Bearer " token] | |
] | |
send-gitter: function [ | |
data | |
"Send GET request to gitter API" | |
] [ | |
type: 'GET | |
value: none | |
link: copy https://api.gitter.im/v1/ | |
args-rule: [ | |
'? (change back tail link #"?") | |
some [ | |
set value set-word! (append link rejoin [form value #"="]) | |
set value [word! | string! | integer!] ( | |
if word? value [value: get :value] | |
append link rejoin [value #"&"] | |
) | |
] | |
] | |
parse append clear [] data [ | |
some [ | |
args-rule | |
| set value [set-word! | file!] (append link dirize form value) | |
| set value word! (append link dirize get :value) | |
] | |
] | |
remove back tail link | |
header: probe compose/deep [ | |
(type) [ | |
Accept: "application/json" | |
Authorization: (bearer token) | |
] | |
] | |
write/info link header | |
] | |
user-info: does [send-gitter %user] | |
user-info | |
user-info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment