github :: GithubWallet :: api
If no token is found, return an api based on the last exhausted token.
# Get an instance of GithubAPI based on the next available token.
#
# If no token is found, return an api based on the last exhausted token.
fun api: GithubAPI do
var token
if tokens.is_empty then
logger.warn "No tokens, using `get_github_oauth`"
token = get_github_oauth
else
token = get_next_token
var tried = 0
while not check_token(token) do
if tried >= tokens.length - 1 then
logger.warn "Exhausted all tokens, using {token}"
break
end
tried += 1
token = get_next_token
end
end
var api = new GithubAPI(token)
api.enable_cache = true
return api
end
lib/github/wallet.nit:98,2--121,4