1
0
Fork 0

Fetch user task

This commit is contained in:
Gregory Eremin 2015-03-11 19:10:29 +07:00
parent e58046f227
commit e805dc53a7
1 changed files with 29 additions and 0 deletions

29
task/user.go Normal file
View File

@ -0,0 +1,29 @@
package task
import (
"time"
"github.com/google/go-github/github"
"github.com/localhots/empact/db"
)
func FetchUserInfo(token, login string) (u *db.User, err error) {
defer report("FetchUserInfo", time.Now())
client := newGithubClient(token)
var user *github.User
var resp *github.Response
if user, resp, err = client.Users.Get(login); err != nil {
return
}
saveResponseMeta(token, resp)
u = &db.User{
Login: *user.Login,
Name: *user.Name,
ID: uint64(*user.ID),
AvatarURL: *user.AvatarURL,
}
return
}