untappd-api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Jeff Smith
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4,13 +4,12 @@ A simple Ruby wrapper for accessing the Untappd API.
4
4
  For more information, see http://untappd.com/api/dashboard.
5
5
 
6
6
  == Usage
7
- Each method returns a Hashie::Mash (an extended Hash that gives object-like access, see https://github.com/intridea/hashie) or an Array of Hashie::Mash.
7
+ Each method returns a Hash representing the response.
8
8
 
9
9
  === Example:
10
10
  require 'untappd-api'
11
11
 
12
- client = Untappd::Base.new("gambrinus", PASSWORD, API_KEY)
13
- client.user.first_name #=> "Jeff"
14
- beer = client.beer_info(:bid => 17904)
15
- beer.name #=> "Third Coast Old Ale"
16
- beer.brewery #=> "Bell's Brewery, Inc."
12
+ client = Untappd::Base.new(API_KEY)
13
+ beer = client.beer_info(:bid => 17904)["results"]
14
+ beer["name"] # => "Third Coast Old Ale"
15
+ beer["brewery"] #=> "Bell's Brewery, Inc."
@@ -1,20 +1,29 @@
1
1
  require 'httparty'
2
- require 'hashie'
3
2
  require 'digest/md5'
4
3
 
5
- Hash.send :include, Hashie::HashExtensions
6
-
7
4
  module Untappd
8
5
  class Base
9
6
  include HTTParty
10
- BASE_URI = 'http://api.untappd.com/v2'
7
+ BASE_URI = 'http://api.untappd.com/v3'
11
8
  base_uri BASE_URI
12
9
 
13
- def initialize(user, pass, key)
14
- @auth = { :username => user, :password => Digest::MD5.hexdigest(pass) }
10
+ def initialize(key, user = nil, pass = nil)
11
+ @auth = {}
12
+ if user && pass
13
+ @auth = { :username => user, :password => Digest::MD5.hexdigest(pass) }
14
+ end
15
15
  @key = key
16
16
  end
17
17
 
18
+ # Get the beer's feed
19
+ # Params:
20
+ # :bid => Your API Key provided when you are approved
21
+ # :since => The numeric ID of the last recent check-in. (Optional)
22
+ # :offset => The offset that you like the dataset to begin with. (Optional)
23
+ def beer_feed(params={})
24
+ get('beer_checkins', params)
25
+ end
26
+
18
27
  # Get extended information about a beer.
19
28
  # Params:
20
29
  # :bid => The numeric beer ID of the beer you wish to look up.
@@ -29,11 +38,20 @@ module Untappd
29
38
  get('beer_search', params)
30
39
  end
31
40
 
41
+ # Get the brewery's feed
42
+ # Params:
43
+ # :brewery_id => Your API Key provided when you are approved
44
+ # :since => The numeric ID of the last recent check-in. (Optional)
45
+ # :offset => The offset that you like the dataset to begin with. (Optional)
46
+ def brewery_feed(params={})
47
+ get('brewery_checkins', params)
48
+ end
49
+
32
50
  # Get extended details for a particular checkin,
33
51
  # which includes location, comments and toasts.
34
52
  # Params:
35
53
  # :id => The numeric ID of the check-in.
36
- def checkin_details(params={})
54
+ def checkin_info(params={})
37
55
  get('details', params)
38
56
  end
39
57
 
@@ -55,12 +73,22 @@ module Untappd
55
73
  get('thepub', params)
56
74
  end
57
75
 
76
+ # Get currently trending beers.
77
+ # Params:
78
+ # :type => "all", "macro", "micro", "local". "all" set to default. (Optional)
79
+ # :limit => The number of records that will return (max 10). (Optional)
80
+ # :age => "daily", "weekly", "monthly". (Optional)
81
+ # :geolat => The numeric Latitude to filter the public feed. (Optional, required for type "local")
82
+ # :geolng => The numeric Longitude to filter the public feed. (Optional, required for type "local")
83
+ def trending(params={})
84
+ get('trending', params)
85
+ end
86
+
58
87
  # Get the user information for a selected user.
59
88
  # Params:
60
89
  # :user => The username of the person who you wish to obtain the user information. (Optional)
61
- def user(params={})
62
- result = get('user', params)
63
- result.user unless result.nil?
90
+ def user_info(params={})
91
+ get('user', params)
64
92
  end
65
93
 
66
94
  # Get a list of the user's badges.
@@ -104,17 +132,35 @@ module Untappd
104
132
  get('wish_list', params)
105
133
  end
106
134
 
135
+ # Get the venue's feed
136
+ # Params:
137
+ # :venue_id => Your API Key provided when you are approved
138
+ # :since => The numeric ID of the last recent check-in. (Optional)
139
+ # :offset => The offset that you like the dataset to begin with. (Optional)
140
+ def venue_feed(params={})
141
+ get('venue_checkins', params)
142
+ end
143
+
144
+ # Get extended information about a venue.
145
+ # Params:
146
+ # :venue_id => The numeric beer ID of the beer you wish to look up.
147
+ def venue_info(params={})
148
+ get('venue_info', params)
149
+ end
150
+
107
151
  private
108
152
 
109
153
  def get(method, params={})
110
154
  path = "/#{method}?key=#{@key}"
111
155
  params.each { |k,v| path += "&#{k.to_s}=#{v.to_s}" }
112
156
 
113
- options = {:basic_auth => @auth}
157
+ options = {}
158
+ options.merge({:basic_auth => @auth}) unless @auth.empty?
159
+
114
160
  response = self.class.get(URI.escape(path), options)
115
161
  raise_errors(response)
116
162
 
117
- response.parsed_response.to_mash.results
163
+ response.parsed_response
118
164
  end
119
165
 
120
166
  def raise_errors(response)
@@ -1,3 +1,3 @@
1
1
  module Untappd
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,103 +1,5 @@
1
1
  require 'untappd-api'
2
2
 
3
3
  describe Untappd::Base do
4
- before do
5
- @user = "YOUR_USERNAME"
6
- pass = "YOUR_PASSWORD"
7
- key = "YOUR_KEY"
8
- @client = Untappd::Base.new(@user, pass, key)
9
- end
10
-
11
- describe "beer_info method" do
12
- it "should find the correct beer" do
13
- beer_name = "Hocus Pocus"
14
- @client.beer_info(:bid => 1).name.should == beer_name
15
- end
16
-
17
- it "should raise Unauthorized exception with bad parameters" do
18
- expect {
19
- @client.beer_info
20
- }.to raise_exception(Untappd::Unauthorized, /You must provide a beer id to continue/)
21
- end
22
- end
23
-
24
- describe "beer_search method" do
25
- it "should return an Array of search results" do
26
- @client.beer_search(:q => "Devil").size.should >= 0
27
- end
28
-
29
- it "should raise Unavailable exception with bad parameters" do
30
- expect {
31
- @client.beer_search
32
- }.to raise_exception(Untappd::Unavailable, /You have not passed anything to search/)
33
- end
34
- end
35
-
36
- describe "checkin_details method" do
37
- it "should return the checkin details for given checkin id" do
38
- pending("Checkin id is currently not exposed.")
39
- end
40
-
41
- it "should raise Unauthorized exception with bad parameters" do
42
- expect {
43
- @client.checkin_details
44
- }.to raise_exception(Untappd::Unauthorized, /You must provide a check-in ID to continue/)
45
- end
46
- end
47
-
48
- describe "friend_feed method" do
49
- it "should return the authenticated user's friend feed" do
50
- @client.friend_feed.size.should >= 0
51
- end
52
- end
53
-
54
- describe "public_feed method" do
55
- it "should return the public feed" do
56
- @client.public_feed.size.should >= 0
57
- end
58
- end
59
-
60
- describe "user method" do
61
- it "should return the authenticated user if no user specified" do
62
- @client.user.user_name.should == @user
63
- end
64
-
65
- it "should return the specified user if user parameter is set" do
66
- @client.user(:user => "gambrinus").user_name.should == "gambrinus"
67
- end
68
-
69
- it "should return nil if the specified user is not found" do
70
- @client.user(:user => ".....").should be_nil
71
- end
72
- end
73
-
74
- describe "user_badges method" do
75
- it "should return the authenticated user's badges" do
76
- @client.user_badges.size.should >= 0
77
- end
78
- end
79
-
80
- describe "user_distinct_beers method" do
81
- it "should return the authenticated user's distinct beers" do
82
- @client.user_distinct_beers.size.should >= 0
83
- end
84
- end
85
-
86
- describe "user_feed method" do
87
- it "should return the authenticated user's feed" do
88
- @client.user_feed.size.should >= 0
89
- end
90
- end
91
-
92
- describe "user_friends method" do
93
- it "should return the authenticated user's friends" do
94
- @client.user_friends.size.should >= 0
95
- end
96
- end
97
-
98
- describe "user_wish_list method" do
99
- it "should return the authenticated user's wish list" do
100
- @client.user_wish_list.size.should >= 0
101
- end
102
- end
4
+ pending "Add some tests..."
103
5
  end
@@ -25,15 +25,12 @@ Gem::Specification.new do |s|
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
26
  s.add_development_dependency %q<rspec>, ['~> 2.0.0.beta.22']
27
27
  s.add_dependency %q<httparty>, ['~> 0.7.4']
28
- s.add_dependency %q<hashie>, ['~> 1.0.0']
29
28
  else
30
29
  s.add_dependency %q<rspec>, ['~> 2.0.0.beta.22']
31
30
  s.add_dependency %q<httparty>, ['~> 0.7.4']
32
- s.add_dependency %q<hashie>, ['~> 1.0.0']
33
31
  end
34
32
  else
35
33
  s.add_dependency %q<rspec>, ['~> 2.0.0.beta.22']
36
34
  s.add_dependency %q<httparty>, ['~> 0.7.4']
37
- s.add_dependency %q<hashie>, ['~> 1.0.0']
38
35
  end
39
36
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeff Smith
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-20 00:00:00 -05:00
17
+ date: 2011-02-28 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -49,21 +49,6 @@ dependencies:
49
49
  version: 0.7.4
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: hashie
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- segments:
61
- - 1
62
- - 0
63
- - 0
64
- version: 1.0.0
65
- type: :runtime
66
- version_requirements: *id003
67
52
  description: Ruby wrapper for the untappd API.
68
53
  email:
69
54
  - jffreyjs@gmail.com
@@ -76,6 +61,7 @@ extra_rdoc_files: []
76
61
  files:
77
62
  - .gitignore
78
63
  - Gemfile
64
+ - MIT-LICENSE
79
65
  - README.rdoc
80
66
  - Rakefile
81
67
  - lib/untappd-api.rb