Skip to content

Added options to the User.info method #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down
8 changes: 6 additions & 2 deletions lib/untappd/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions spec/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
48 changes: 48 additions & 0 deletions spec/vcr/User/get_info_with_compact.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.