# Default is `https://api.github.com` and should not be changed.
var api_url = "https://api.github.com"
- # Verbosity level.
- #
- # * `0`: only errors (default)
- # * `1`: verbose
- var verbose_lvl = 0 is public writable
-
# Send a HTTPRequest to the Github API
fun send(method, path: String, headers: nullable HeaderMap, body: nullable String): nullable String do
last_error = null
return res
end
- # Display a message depending on `verbose_lvl`.
- fun message(lvl: Int, message: String) do
- if lvl <= verbose_lvl then print message
- end
-
# Escape `uri` in an acceptable format for Github.
private fun sanitize_uri(uri: String): String do
# TODO better URI escape.
redef fun get(key, headers, data) do
if not enable_cache then return super
if store.has_key(key) then
- message(1, "Get {key} (cache)")
+ # print "Get {key} (cache)" # debug
was_error = false
return deserialize(store.load_object(key).to_json)
end
# Save `json` data in cache under `key`.
private fun cache(key: String, obj: Serializable) do
- message(2, "Cache key {key}")
+ # print "Cache key {key}" # debug
store.store_object(key, obj.to_json.parse_json.as(JsonObject))
end