2015-03-04 19:08:36 +00:00
|
|
|
package task
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.google.com/p/goauth2/oauth"
|
|
|
|
"github.com/google/go-github/github"
|
2015-03-05 08:07:18 +00:00
|
|
|
"github.com/localhots/empact/db"
|
2015-03-04 19:08:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newGithubClient(token string) *github.Client {
|
|
|
|
trans := &oauth.Transport{
|
|
|
|
Token: &oauth.Token{AccessToken: token},
|
|
|
|
}
|
|
|
|
return github.NewClient(trans.Client())
|
|
|
|
}
|
2015-03-04 19:15:05 +00:00
|
|
|
|
2015-03-04 20:14:14 +00:00
|
|
|
func saveResponseMeta(token string, res *github.Response) {
|
|
|
|
if res == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
db.UpdateToken(&db.Token{
|
|
|
|
Token: token,
|
|
|
|
Limit: res.Limit,
|
|
|
|
Remaining: res.Remaining,
|
|
|
|
ResetAt: res.Reset.Time,
|
|
|
|
})
|
|
|
|
}
|