From d4f874c0f4c3752f5d18503415307106ed7c3837 Mon Sep 17 00:00:00 2001 From: LEGOlord208 Date: Mon, 13 Mar 2017 18:10:58 +0100 Subject: [PATCH] UserAvatar to accept user object. (#337) * UserAvatar to accept user object. One of the most important thing with this library is that it does 1 request per function. You have 100% control over how many web requests get made. UserAvatar breaks that. UserAvatar now accepts a user, which not only makes you know how many web requests gets made, but might also save on web requests if you have an existing user object. * Removed dots. Please work, travis :< * Ohhh... A friend spotted the error! * `go fmt` and fixed comment... PLS TRAVIS --- restapi.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/restapi.go b/restapi.go index 4d8a940..5435b46 100644 --- a/restapi.go +++ b/restapi.go @@ -262,15 +262,21 @@ func (s *Session) User(userID string) (st *User, err error) { return } -// UserAvatar returns an image.Image of a users Avatar. +// UserAvatar is deprecated. Please use UserAvatarDecode // userID : A user ID or "@me" which is a shortcut of current user ID func (s *Session) UserAvatar(userID string) (img image.Image, err error) { u, err := s.User(userID) if err != nil { return } + img, err = s.UserAvatarDecode(u) + return +} - body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(userID, u.Avatar), nil, EndpointUserAvatar("", "")) +// UserAvatarDecode returns an image.Image of a user's Avatar +// user : The user which avatar should be retrieved +func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) { + body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(u.ID, u.Avatar), nil, EndpointUserAvatar("", "")) if err != nil { return }