#
# To access the API you need an instance of a `GithubAPI` client.
#
-# ~~~
+# ~~~nitish
# # Get Github authentification token.
# var token = get_github_oauth
# assert not token.is_empty
#
# The API client allows you to get Github API entities.
#
-# ~~~
+# ~~~nitish
# var repo = api.load_repo("nitlang/nit")
# assert repo != null
# assert repo.name == "nit"
# assert err isa GithubError
# assert err.name == "GithubAPIError"
# assert err.message == "Not Found"
- fun get(path: String): nullable Jsonable do
+ fun get(path: String): nullable Serializable do
path = sanitize_uri(path)
var res = ghcurl.get_and_parse("{api_url}{path}")
if res isa Error then
var array = get("/repos/{repo.full_name}/branches")
var res = new Array[Branch]
if not array isa JsonArray then return res
- return deserialize(array.to_json).as(Array[Branch])
+ var deser = deserialize(array.to_json)
+ if deser isa Array[Object] then return res # empty array
+ return deser.as(Array[Branch])
end
# List of issues associated with their ids.
#
# Mainly a Nit wrapper around a JSON objet.
abstract class GithubEntity
- super Jsonable
serialize
# Github page url.
var closed_by: nullable User is writable
# Is this issue linked to a pull request?
- var is_pull_request: Bool = false is writable, noserialize
+ var is_pull_request: Bool = false is writable
end
# A Github pull request.
serialize
# The milestone id on Github.
- var number: Int is writable
+ var number: nullable Int = null is writable
# Milestone title.
var title: String is writable
var description: nullable String is writable
# Count of opened issues linked to this milestone.
- var open_issues: Int is writable
+ var open_issues: nullable Int = null is writable
# Count of closed issues linked to this milestone.
- var closed_issues: Int is writable
+ var closed_issues: nullable Int = null is writable
# Milestone state.
var state: nullable String is writable
# Make ISO Datew serilizable
redef class ISODate
- super Jsonable
serialize
end