From e805dc53a72e7462028f23676fc34c007d0ad6da Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 11 Mar 2015 19:10:29 +0700 Subject: [PATCH] Fetch user task --- task/user.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 task/user.go diff --git a/task/user.go b/task/user.go new file mode 100644 index 0000000..0feccf6 --- /dev/null +++ b/task/user.go @@ -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 +}