|
| 1 | +# Untappd |
| 2 | + |
| 3 | +Wrapper around the Untappd API. This organizes the untappd api |
| 4 | +into proper RESTFUL objects. See API coverage below for mapping from |
| 5 | +the API documentation. |
| 6 | + |
| 7 | +* You will need to register for an API key: http://untappd.com/api/register. |
| 8 | +* Attempting to wrap all the API documented here: https://untappd.com/api/docs/v4. |
| 9 | +* Required parameters are passed as arguments to the method, optional parameters should be included in the options hash. |
| 10 | +* Methods requiring user authentication will require an OAuth access_token. See OAuth Examples below. |
| 11 | +* All responses are wrapped in a Hashie::Mash |
| 12 | + |
| 13 | +## Releases |
| 14 | + |
| 15 | +* 0.0.5 Brewery Info and Search |
| 16 | +* 0.0.4 Complete coverage of v3 API. Checkins, Comments, Toasts, gmt_offset configuration |
| 17 | +* 0.0.3 Venue Info & Feed, Trending Beer, Brewery Feed, Checkin info & Feed (the pub), Renamed Beer.checkins to Beer.feed |
| 18 | +* 0.0.2 User feed, distinct beers, info, badges, friends, wish list |
| 19 | +* 0.0.1 Beer Search, Info and Checkins |
| 20 | + |
| 21 | +## API Coverage |
| 22 | + |
| 23 | +**Beer Object** |
| 24 | +* Beer Feed - Untappd::Beer.feed(beer_id, options={}) |
| 25 | +* Beer Info - Untappd::Beer.info(beer_id, options={}) |
| 26 | +* Beer Search - Untappd::Beer.search(q, options={}) |
| 27 | +* Trending - Untappd::Beer.trending |
| 28 | + |
| 29 | +**User Object** |
| 30 | +* User Feed - Untappd::User.feed(username, options={}) |
| 31 | +* User Info - Untappd::User.info(username) |
| 32 | +* User Badges - Untappd::User.badges(username, options={}) |
| 33 | +* User Friends - Untappd::User.friends(username, options={}) |
| 34 | +* User Wish List - Untappd::User.wish_list(username, options={}) |
| 35 | +* User Distinct Beers - Untappd::User.distinct(username, options={}) |
| 36 | +* Friend Feed - Untappd::User.friend_feed(access_token, options={}) |
| 37 | + |
| 38 | +**Venue Object** |
| 39 | +* Venue Feed - Untappd::Venue.feed(venue_id, options={}) |
| 40 | +* Venue Info - Untappd::Venue.info(venue_id) |
| 41 | + |
| 42 | +**Brewery Object** |
| 43 | +* Brewery Checkins - Untappd::Brewery.feed(brewery_id, options={}) |
| 44 | +* Brewery Info - Untappd::Brewery.info(brewery_id) |
| 45 | +* Brewery Search - Untappd::Brewery.search(q) |
| 46 | + |
| 47 | +**Checkin Object** |
| 48 | +* Checkin Info - Untappd::Checkin.info(checkin_id) |
| 49 | +* The Pub Feed - Untappd::Checkin.feed(options={}) |
| 50 | +* Checkin - Untappd::Checkin.create(access_token, gmt_offset, timezone, beer_id, options={}) |
| 51 | +* Add Comment - Untappd::Checkin.add_comment(access_token, checkin_id, comment) |
| 52 | +* Remove Comment - Untappd::Checkin.remove_comment(access_token, comment_id) |
| 53 | +* Toast/Remove Toast - Untappd::Checkin.toggle_toast(access_token, checkin_id) |
| 54 | + |
| 55 | +**TODO** |
| 56 | +* Add To Wish List - /v4/user/wishlist/add |
| 57 | +* Remove From Wish List - /v4/user/wishlist/delete |
| 58 | +* Pending Friends - /v4/user/pending |
| 59 | +* Accept Friends - /v4/friend/accept/TARGET_ID |
| 60 | +* Reject Friends - /v4/friend/reject/TARGET_ID |
| 61 | +* Remove Friends - /v4/friend/remove/TARGET_ID |
| 62 | +* Request Friends - /v4/friend/request/TARGET_ID |
| 63 | +* Notifications - /v4/notifications |
| 64 | +* Foursquare Venue Lookup - /v4/venue/foursquare_lookup/VENUE_ID |
| 65 | + |
| 66 | +## Examples |
| 67 | + |
| 68 | +### Configuration |
| 69 | + |
| 70 | +Add to your Gemfile |
| 71 | + |
| 72 | + gem 'untappd' |
| 73 | + |
| 74 | +Configure your API KEY |
| 75 | + |
| 76 | + Untappd.configure do |config| |
| 77 | + config.client_id = 'YOUR_CLIENT_ID' |
| 78 | + config.client_secret = 'YOUR_CLIENT_SECRET' |
| 79 | + config.redirect_url = 'YOUR_OAUTH_REDIRECT_URL' # only if you're using OAuth |
| 80 | + config.gmt_offset = -5 |
| 81 | + end |
| 82 | + |
| 83 | +### OAuth |
| 84 | + |
| 85 | +To generate an OAuth authentication request, simply call |
| 86 | + |
| 87 | + Untappd::OAuth.authenticate_url |
| 88 | + |
| 89 | +This will generate a URL that the user can access in order to authorize the application. |
| 90 | +It will look something like this: |
| 91 | + |
| 92 | + => "https://untappd.com/oauth/authenticate/?client_id=YOUR_CLIENT_ID&response_type=token&redirect_url=YOUR_OAUTH_REDIRECT_URL" |
| 93 | + |
| 94 | +After the user has authenticated your application, they will be redirected back to `YOUR_OAUTH_REDIRECT_URL` with their access token appended to the query string. |
| 95 | + |
| 96 | +### Examples |
| 97 | + |
| 98 | +Get all the checkins for Arrogant Bastard Ale |
| 99 | + |
| 100 | + checkins = Untappd::Beer.feed(18099) # or Untappd::User.feed("cmar") |
| 101 | + checkins.checkins.items.each do |checkin| |
| 102 | + puts "#{checkin.user.first_name} at #{checkin.created_at}" |
| 103 | + end |
| 104 | + |
| 105 | +Create Checkin |
| 106 | + |
| 107 | + #foursqure, lat, lng are optional |
| 108 | + Untappd::Checkin.create(ACCESS_TOKEN, -6, 'CST', 4665 |
| 109 | + :foursquare_id => "4ad6bf91f964a520380821e3", |
| 110 | + :user_lat => "51.4718", |
| 111 | + :user_lng => "-0.489278") |
| 112 | + |
| 113 | +Search for beers with the name Stone |
| 114 | + |
| 115 | + beers = Untappd::Beer.search('stone') |
| 116 | + beers.beers.items.each do |beer| |
| 117 | + puts "#{beer.beer.beer_name}" |
| 118 | + end |
| 119 | + |
| 120 | +Get extended info for Arrogant Bastard Ale |
| 121 | + |
| 122 | + info = Untappd::Beer.info(18099) |
| 123 | + puts "#{info.beer.beer_name} by #{info.beer.brewery.brewery_name}" |
| 124 | + |
| 125 | +All Methods can take additional options specified in the API |
| 126 | + |
| 127 | + checkins = Untappd::Beer.feed(18099, :offset => 100) |
| 128 | + |
| 129 | + beers = Untappd::Beer.search('stone', :sort => "count") |
| 130 | + |
| 131 | +### Debugging |
| 132 | +You can dump any result to see what values are available with |
| 133 | + |
| 134 | + info = Untappd::Beer.info(18099) |
| 135 | + puts info.inspect |
0 commit comments