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/lib/untappd/user.rb b/lib/untappd/user.rb index 4e7649b..09b6aa2 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 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) end # options: diff --git a/spec/user_spec.rb b/spec/user_spec.rb index 943db53..88a601c 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 be_nil + info.user.media.should be_nil + info.user.checkins.should be_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