From 360ddaf2a59f5486ca9dad40068977ebf30e7e45 Mon Sep 17 00:00:00 2001 From: Eric Sanders Date: Fri, 6 Feb 2015 23:16:20 -0600 Subject: [PATCH 1/4] Added options param to the User.info method. Without it options like 'compact' cannot be used. --- lib/untappd/user.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/untappd/user.rb b/lib/untappd/user.rb index 4e7649b..127513c 100644 --- a/lib/untappd/user.rb +++ b/lib/untappd/user.rb @@ -8,8 +8,12 @@ def self.feed(username, options={}) response_to_mash get("/user/checkins/#{username}", :query => options) end - def self.info(username) - response_to_mash get("/user/info/#{username}", :query => auth_options) + # options: + # * compact (string, optional) - You can pass "true" here only show the user infomation, + # and remove the "checkins", "media", "recent_brews", etc attributes + def self.info(username, options={}) + options.merge!(auth_options) + response_to_mash get("/user/info/#{username}", :query => options) end # options: From 1ad84ea54318c29f547702e5f5047f5640ef67ce Mon Sep 17 00:00:00 2001 From: Eric Sanders Date: Fri, 6 Feb 2015 23:20:09 -0600 Subject: [PATCH 2/4] Added a missing word to the comment --- lib/untappd/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/untappd/user.rb b/lib/untappd/user.rb index 127513c..09b6aa2 100644 --- a/lib/untappd/user.rb +++ b/lib/untappd/user.rb @@ -9,8 +9,8 @@ def self.feed(username, options={}) end # options: - # * compact (string, optional) - You can pass "true" here only show the user infomation, - # and remove the "checkins", "media", "recent_brews", etc attributes + # * compact (string, optional) - You can pass "true" here to only show the user + # infomation, and remove the "checkins", "media", "recent_brews", etc attributes def self.info(username, options={}) options.merge!(auth_options) response_to_mash get("/user/info/#{username}", :query => options) From 0b5839f7076239e418f90ddcba0654017816878f Mon Sep 17 00:00:00 2001 From: Eric Sanders Date: Sat, 11 Apr 2015 11:23:07 -0500 Subject: [PATCH 3/4] Updated README.md to reflect that User.info now supports the options param. Added a test to verify that passing compact with true removes the recent_brews, media, and checkin fields from the response. --- README.md | 2 +- spec/user_spec.rb | 10 ++++++ spec/vcr/User/get_info_with_compact.yml | 48 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 spec/vcr/User/get_info_with_compact.yml diff --git a/README.md b/README.md index af9a56f..cb812ac 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ the API documentation. **User Object** * User Feed - Untappd::User.feed(username, options={}) -* User Info - Untappd::User.info(username) +* User Info - Untappd::User.info(username, options={}) * User Badges - Untappd::User.badges(username, options={}) * User Friends - Untappd::User.friends(username, options={}) * User Wish List - Untappd::User.wish_list(username, options={}) diff --git a/spec/user_spec.rb b/spec/user_spec.rb index 943db53..c0cf686 100644 --- a/spec/user_spec.rb +++ b/spec/user_spec.rb @@ -10,6 +10,16 @@ info.user.user_name.should == "cmar" end + it "get info with compact", :vcr do + info = Untappd::User.info("cmar", :compact => true) + info.user.user_name.should == "cmar" + #according to docs recent_brews, media, and checkins should be removed + #when compact=true + info.user.recent_brews.should == nil + info.user.media.should == nil + info.user.checkins.should == nil + end + it "get badges", :vcr do badges = Untappd::User.badges("cmar") badges.items.first.badge_name.should == "American Craft Beer Week (2013)" diff --git a/spec/vcr/User/get_info_with_compact.yml b/spec/vcr/User/get_info_with_compact.yml new file mode 100644 index 0000000..1f143c4 --- /dev/null +++ b/spec/vcr/User/get_info_with_compact.yml @@ -0,0 +1,48 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.untappd.com/v4/user/info/cmar?compact=true&client_id=&client_secret= + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + date: + - Sat, 11 Apr 2015 16:08:35 GMT + server: + - Apache + x-powered-by: + - PHP/5.5.9-1ubuntu4.5 + x-ratelimit-limit: + - '100' + x-ratelimit-remaining: + - '97' + x-auth-type: + - key + x-api-version: + - '4' + x-http-protocol: + - '80' + access-control-allow-origin: + - ! '*' + access-control-allow-headers: + - X-Untappd-App, X-Untappd-App-Version, Content-Type + content-length: + - '1199' + connection: + - close + content-type: + - application/json + body: + encoding: US-ASCII + string: ! '{"meta":{"code":200,"response_time":{"time":0.021,"measure":"seconds"},"init_time":{"time":0.004,"measure":"seconds"}},"notifications":[],"response":{"user":{"uid":10824,"id":10824,"user_name":"cmar","first_name":"cmar","last_name":"","user_avatar":"https:\/\/gravatar.com\/avatar\/cf989ae1f7ddd979f38b00ec033a0e7d?size=100&d=https%3A%2F%2Fd1c8v1qci5en44.cloudfront.net%2Fsite%2Fassets%2Fimages%2Fdefault_avatar_v2.jpg%3Fv%3D1","user_avatar_hd":"https:\/\/gravatar.com\/avatar\/cf989ae1f7ddd979f38b00ec033a0e7d?size=125&d=https%3A%2F%2Fd1c8v1qci5en44.cloudfront.net%2Fsite%2Fassets%2Fimages%2Fdefault_avatar_v2.jpg%3Fv%3D1","user_cover_photo":"https:\/\/untappd.s3.amazonaws.com\/site\/assets\/v3\/images\/cover_default.jpg","user_cover_photo_offset":0,"is_private":0,"location":"Leesburg, + VA","url":"","bio":"","is_supporter":0,"relationship":null,"untappd_url":"http:\/\/untappd.com\/user\/cmar","account_type":"user","stats":{"total_badges":10,"total_friends":2,"total_checkins":19,"total_beers":18,"total_created_beers":1,"total_followings":1,"total_photos":3},"contact":{"twitter":"cmar","foursquare":990366,"facebook":500011785},"date_joined":"Thu, + 23 Dec 2010 17:22:26 +0000","settings":[]}}}' + http_version: '1.1' + recorded_at: Sat, 11 Apr 2015 16:08:57 GMT +recorded_with: VCR 2.3.0 From 742e469453f75cb78e815334254a0bb9c33b5508 Mon Sep 17 00:00:00 2001 From: Eric Sanders Date: Sat, 11 Apr 2015 11:46:22 -0500 Subject: [PATCH 4/4] Updated test to use a be_nil matcher instead of using == nil --- spec/user_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/user_spec.rb b/spec/user_spec.rb index c0cf686..88a601c 100644 --- a/spec/user_spec.rb +++ b/spec/user_spec.rb @@ -15,9 +15,9 @@ info.user.user_name.should == "cmar" #according to docs recent_brews, media, and checkins should be removed #when compact=true - info.user.recent_brews.should == nil - info.user.media.should == nil - info.user.checkins.should == nil + info.user.recent_brews.should be_nil + info.user.media.should be_nil + info.user.checkins.should be_nil end it "get badges", :vcr do