gowalla 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/.document +5 -0
  2. data/.gitignore +25 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +43 -0
  5. data/LICENSE +20 -0
  6. data/README.md +96 -0
  7. data/Rakefile +14 -0
  8. data/changelog.md +33 -0
  9. data/gowalla.gemspec +30 -0
  10. data/lib/gowalla.rb +26 -22
  11. data/lib/gowalla/checkins.rb +31 -0
  12. data/lib/gowalla/client.rb +22 -176
  13. data/lib/gowalla/flags.rb +42 -0
  14. data/lib/gowalla/items.rb +22 -0
  15. data/lib/gowalla/spots.rb +67 -0
  16. data/lib/gowalla/trips.rb +27 -0
  17. data/lib/gowalla/users.rb +91 -0
  18. data/lib/gowalla/version.rb +3 -0
  19. data/test/checkins_test.rb +18 -0
  20. data/test/client_test.rb +72 -0
  21. data/test/fixtures/categories.json +1826 -0
  22. data/test/fixtures/category.json +8 -0
  23. data/test/fixtures/challenges.json +191 -0
  24. data/test/fixtures/checkin.json +21 -0
  25. data/test/fixtures/events.json +185 -0
  26. data/test/fixtures/find_spots.json +620 -0
  27. data/test/fixtures/find_trips.json +695 -0
  28. data/test/fixtures/flag.json +23 -0
  29. data/test/fixtures/flags.json +31 -0
  30. data/test/fixtures/friend_requests.json +21 -0
  31. data/test/fixtures/friends.json +3 -0
  32. data/test/fixtures/friends_recent.json +243 -0
  33. data/test/fixtures/item.json +8 -0
  34. data/test/fixtures/item_events.json +35 -0
  35. data/test/fixtures/items.json +100 -0
  36. data/test/fixtures/me.json +49 -0
  37. data/test/fixtures/missing_items.json +1 -0
  38. data/test/fixtures/new_spot.json +49 -0
  39. data/test/fixtures/photos.json +88 -0
  40. data/test/fixtures/pins.json +81 -0
  41. data/test/fixtures/potential_twitter_friends.json +2090 -0
  42. data/test/fixtures/spot.json +251 -0
  43. data/test/fixtures/spots.json +557 -0
  44. data/test/fixtures/spots_by_category.json +620 -0
  45. data/test/fixtures/spots_urls.json +26 -0
  46. data/test/fixtures/stamps.json +284 -0
  47. data/test/fixtures/top_spots.json +64 -0
  48. data/test/fixtures/trip.json +22 -0
  49. data/test/fixtures/trips.json +881 -0
  50. data/test/fixtures/user.json +43 -0
  51. data/test/fixtures/users.json +46 -0
  52. data/test/fixtures/vaulted_items.json +12 -0
  53. data/test/fixtures/visited_spots.json +1 -0
  54. data/test/flags_test.rb +46 -0
  55. data/test/helper.rb +6 -6
  56. data/test/items_test.rb +26 -0
  57. data/test/spots_test.rb +70 -0
  58. data/test/trips_test.rb +25 -0
  59. data/test/users_test.rb +83 -0
  60. metadata +177 -29
  61. data/test/gowalla_test.rb +0 -214
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ *.gem
21
+ .yardopts
22
+ .yardoc
23
+ .bundle
24
+
25
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gowalla (0.4.0)
5
+ faraday (~> 0.4.5)
6
+ faraday_middleware
7
+ hashie (~> 0.2.0)
8
+ multi_json (~> 0.0.4)
9
+ oauth2
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ addressable (2.2.1)
15
+ fakeweb (1.3.0)
16
+ faraday (0.4.6)
17
+ addressable (>= 2.1.1)
18
+ rack (>= 1.0.1)
19
+ faraday_middleware (0.0.4)
20
+ faraday (~> 0.4.5)
21
+ hashie (0.2.2)
22
+ jnunemaker-matchy (0.4.0)
23
+ multi_json (0.0.4)
24
+ oauth2 (0.0.13)
25
+ faraday (~> 0.4.1)
26
+ multi_json (>= 0.0.4)
27
+ rack (1.2.1)
28
+ shoulda (2.10.3)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (>= 1.0.0)
35
+ fakeweb
36
+ faraday (~> 0.4.5)
37
+ faraday_middleware
38
+ gowalla!
39
+ hashie (~> 0.2.0)
40
+ jnunemaker-matchy (~> 0.4.0)
41
+ multi_json (~> 0.0.4)
42
+ oauth2
43
+ shoulda (~> 2.10.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Wynn Netherland
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.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Gowalla
2
+
3
+ Ruby wrapper for the [Gowalla API](http://gowalla.com/api/docs).
4
+
5
+
6
+ ## Installation
7
+
8
+ sudo gem install gowalla
9
+
10
+ ## Get your API key
11
+
12
+ Be sure and get your API key: [http://gowalla.com/api/keys](http://gowalla.com/api/keys)
13
+
14
+ ## Usage
15
+
16
+ ### Instantiate a client (Basic Auth)
17
+
18
+ gowalla = Gowalla::Client.new(:username => 'pengwynn', :password => 'somepassword', :api_key => 'your_api_key')
19
+
20
+ ### or configure once
21
+
22
+ Gowalla.configure do |config|
23
+ config.api_key = 'your_api_key'
24
+ config.username = 'pengwynn'
25
+ config.password = 'somepassword'
26
+ end
27
+ gowalla = Gowalla::Client.new
28
+
29
+ ### Instantiate a client (OAuth2)
30
+
31
+ For OAuth2, you'll need to specify a callback URL when you [set up your app and get your API keys](http://gowalla.com/api/keys).
32
+
33
+ Let's create the client in a protected method in our controller:
34
+
35
+ protected
36
+ def client
37
+ Gowalla::Client.new (
38
+ :api_key => "your_api_key",
39
+ :api_secret => "your_api_secret",
40
+ :access_token => session[:access_token]
41
+ )
42
+ end
43
+
44
+ We need to get an access token. Perhaps in an a before filter where you need to access Gowalla:
45
+
46
+ redirect(@client.web_server.authorize_url(:redirect_uri => redirect_uri, :state => 1))
47
+
48
+ or if you need read-write access:
49
+
50
+ redirect(@client.web_server.authorize_url(:redirect_uri => redirect_uri, :state => 1, :scope => 'read-write))
51
+
52
+ You'll need a callback route to catch the code coming back from Gowalla after a user grants you access and this must match what you specified when you created your app on Gowalla:
53
+
54
+ get '/auth/gowalla/callback' do
55
+ session[:access_token] = client.web_server.get_access_token(params[:code], :redirect_uri => redirect_uri).token
56
+
57
+ if session[:access_token]
58
+ redirect '/auth/gowalla/test'
59
+ else
60
+ "Error retrieving access token."
61
+ end
62
+ end
63
+
64
+ Now that we have an access token we can use the client to make calls, just like we would with Basic Auth. You can checkout a basic [Sinatra example](http://gist.github.com/454283).
65
+
66
+ #### Examples
67
+
68
+ gowalla.user('pengwynn')
69
+ => <#Hashie::Mash accept_url="/friendships/accept?user_id=1707" activity_url="/users/1707/events" bio="Web designer and Ruby developer." events_url="/users/1707/events" fb_id=605681706 first_name="Wynn" friends_count=27 friends_only=false friends_url="/users/1707/friends" hometown="Aubrey, TX" image_url="http://s3.amazonaws.com/static.gowalla.com/users/1707-standard.jpg?1262011383" is_friend=false items_count=5 items_url="/users/1707/items" last_name="Netherland" last_visit=<#Hashie::Mash comment="Closing every account I have " created_at="2010/01/26 15:31:46 +0000" spot=<#Hashie::Mash image_url="http://static.gowalla.com/categories/186-standard.png" name="Bank Of America" small_image_url="http://static.gowalla.com/categories/186-small-standard.png" url="/spots/164052"name="Wynn Netherland" pins_count=3 pins_url="/users/1707/pins" reject_url="/friendships/reject?user_id=1707" request_url="/friendships/request?user_id=1707" stamps_count=15 stamps_url="/users/1707/stamps" top_spots_url="/users/1707/top_spots" twitter_username="pengwynn" url="/users/1707" username="pengwynn" vaulted_kinds_count=0 visited_spots_count=15 website="http://wynnnetherland.com">
70
+
71
+
72
+ Details for the current user
73
+
74
+ gowalla.user
75
+
76
+ Details for another user
77
+
78
+ gowalla.user('bradleyjoyce')
79
+ gowalla.user(1707)
80
+
81
+
82
+
83
+ ## Note on Patches/Pull Requests
84
+
85
+ * Fork the project.
86
+ * Make your feature addition or bug fix.
87
+ * Add tests for it. This is important so I don't break it in a
88
+ future version unintentionally.
89
+ * Commit, do not mess with rakefile, version, or history.
90
+ (if you want to have your own version, that is fine but
91
+ bump version in a commit by itself I can ignore when I pull)
92
+ * Send me a pull request. Bonus points for topic branches.
93
+
94
+ ## Copyright
95
+
96
+ Copyright (c) 2010 Wynn Netherland. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rake'
2
+ require "shoulda/tasks"
3
+ require "rake/testtask"
4
+ require 'bundler'
5
+
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ Rake::TestTask.new(:test) do |test|
9
+ test.ruby_opts = ["-rubygems"] if defined? Gem
10
+ test.libs << "lib" << "test"
11
+ test.pattern = "test/**/*_test.rb"
12
+ end
13
+
14
+ task :default => :test
data/changelog.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+ ## 0.4.0 September 28, 2010
3
+ * faraday_middleware gem renamed
4
+ * refactor api methods into individual container classes
5
+ * Additional user method support (visited spots, pins)
6
+ * Problem reporting via flags
7
+ * Patch from [armanddp](http://github.com/armanddp) for Ruby 1.9, Bundler
8
+ ## 0.3.0 August 9, 2010
9
+ * Added checkin API
10
+ * Patch from [mattt](http://github.com/mattt) for Flag Spots API
11
+ ## 0.2.1 June 28, 2010
12
+ * Use Faraday middleware for JSON parsing, Mash creation
13
+ ## 0.2.0 June 27, 2010
14
+ * Refactored to use Faraday
15
+ * Now supports OAuth2
16
+ ## 0.1.4 May 6, 2010
17
+ * Updated accepts header
18
+ * Added patch from [Ruben Fonseca](http://github.com/rubenfonseca) to check in at a spot
19
+ ## 0.1.3 March 7, 2010
20
+ * Updated README with correct config call
21
+ * Applied patch from [Kacy Fortner](http://github.com/kacy) to add vaulted items and missing items calls
22
+ * Applied patches from [Eric Hutzelman](http://github.com/ehutzelman) to clean up fixtures, changed api methods
23
+ ## 0.1.2 March 3, 2010
24
+
25
+ * Applied patch from [Ruben Fonseca](http://github.com/rubenfonseca) to search within a given bounds
26
+ * Applied patch from [Eric Hutzelman](http://github.com/ehutzelman) to clean up config
27
+
28
+ ## 0.1.0 February 8, 2010
29
+
30
+ * Updates for released API
31
+
32
+ ## 0.0.1 January 28, 2010
33
+ * Initial version
data/gowalla.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/gowalla/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{gowalla}
6
+ s.version = Gowalla::VERSION
7
+ s.authors = ["Wynn Netherland", "Eric Hutzelman"]
8
+ s.email = %q{wynn.netherland@gmail.com}
9
+ s.summary = %q{Wrapper for the Gowalla API}
10
+ s.description = %q{Ruby wrapper for the Gowalla API}
11
+ s.homepage = %q{http://wynnnetherland.com/projects/gowalla/}
12
+
13
+ s.add_dependency 'oauth2'
14
+ s.add_dependency 'faraday', '~> 0.4.5'
15
+ s.add_dependency 'hashie', '~> 0.2.0'
16
+ s.add_dependency 'multi_json', '~> 0.0.4'
17
+ s.add_dependency 'faraday_middleware'
18
+
19
+ s.add_development_dependency 'shoulda', '~> 2.10.0'
20
+ s.add_development_dependency 'jnunemaker-matchy', '~> 0.4.0'
21
+ s.add_development_dependency 'fakeweb'
22
+ s.add_development_dependency "bundler", ">= 1.0.0"
23
+
24
+ s.required_rubygems_version = ">= 1.3.6"
25
+ s.platform = Gem::Platform::RUBY
26
+ s.require_path = 'lib'
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
30
+ end
data/lib/gowalla.rb CHANGED
@@ -9,24 +9,6 @@ directory = File.expand_path(File.dirname(__FILE__))
9
9
  Hash.send :include, Hashie::HashExtensions
10
10
 
11
11
  module Gowalla
12
-
13
- VERSION = "0.3.0".freeze
14
-
15
- # config/initializers/gowalla.rb (for instance)
16
- #
17
- # Gowalla.configure do |config|
18
- # config.api_key = 'api_key'
19
- # config.username = 'username'
20
- # config.password = 'password'
21
- # end
22
- #
23
- # elsewhere
24
- #
25
- # client = Gowalla::Client.new
26
- def self.configure
27
- yield self
28
- true
29
- end
30
12
 
31
13
  class << self
32
14
  attr_accessor :api_key
@@ -34,12 +16,34 @@ module Gowalla
34
16
  attr_accessor :password
35
17
  attr_accessor :api_secret
36
18
  attr_accessor :test_mode
37
-
19
+
20
+ # config/initializers/gowalla.rb (for instance)
21
+ #
22
+ # Gowalla.configure do |config|
23
+ # config.api_key = 'api_key'
24
+ # config.username = 'username'
25
+ # config.password = 'password'
26
+ # end
27
+ #
28
+ # elsewhere
29
+ #
30
+ # client = Gowalla::Client.new
31
+ def configure
32
+ yield self
33
+ true
34
+ end
35
+
38
36
  def test_mode?
39
37
  !!self.test_mode
40
38
  end
41
39
  end
42
-
43
- end
44
40
 
45
- require File.join(directory, 'gowalla', 'client')
41
+ require 'gowalla/spots'
42
+ require 'gowalla/items'
43
+ require 'gowalla/trips'
44
+ require 'gowalla/checkins'
45
+ require 'gowalla/flags'
46
+ require 'gowalla/users'
47
+ require 'gowalla/client'
48
+
49
+ end
@@ -0,0 +1,31 @@
1
+ module Gowalla
2
+ module Checkins
3
+
4
+ # Fetch info for a checkin
5
+ #
6
+ # @param [Integer] id Checkin ID
7
+ # @return [Hashie::Mash] checkin info
8
+ def checkin_info(id)
9
+ connection.get("/checkins/#{id}").body
10
+ end
11
+
12
+ # Check in at a spot
13
+ #
14
+ # @option details [Integer] :spot_id Spot ID
15
+ # @option details [Float] :lat Latitude of spot
16
+ # @option details [Float] :lng Longitude of spot
17
+ # @option details [String] :comment Checkin comment
18
+ # @option details [Boolean] :post_to_twitter Post Checkin to Twitter
19
+ # @option details [Boolean] :post_to_facebook Post Checkin to Facebook
20
+ def checkin(details={})
21
+ checkin_path = "/checkins"
22
+ checkin_path += "/test" if Gowalla.test_mode?
23
+ response = connection.post do |req|
24
+ req.url checkin_path
25
+ req.body = details
26
+ end
27
+ response.body
28
+ end
29
+
30
+ end
31
+ end
@@ -3,11 +3,18 @@ require 'forwardable'
3
3
  module Gowalla
4
4
  class Client
5
5
  extend Forwardable
6
-
6
+
7
+ include Spots
8
+ include Users
9
+ include Items
10
+ include Trips
11
+ include Checkins
12
+ include Flags
13
+
7
14
  attr_reader :username, :api_key, :api_secret
8
-
15
+
9
16
  def_delegators :oauth_client, :web_server, :authorize_url, :access_token_url
10
-
17
+
11
18
  def initialize(options={})
12
19
  @api_key = options[:api_key] || Gowalla.api_key
13
20
  @api_secret = options[:api_secret] || Gowalla.api_secret
@@ -17,176 +24,15 @@ module Gowalla
17
24
  connection.basic_auth(@username, password) unless @api_secret
18
25
  connection.token_auth(@access_token) if @access_token
19
26
  end
20
-
21
- # Retrieve information about a specific user
22
- #
23
- # @param [String] user_id (authenticated basic auth user) User ID (screen name)
24
- # @return [Hashie::Mash] User info
25
- def user(user_id=nil)
26
- user_id ||= username
27
- connection.get("/users/#{user_id}").body
28
- end
29
-
30
- # Retrieve information about a specific item
31
- #
32
- # @param [Integer] id Item ID
33
- # @return [Hashie::Mash] item info
34
- def item(id)
35
- connection.get("/items/#{id}").body
36
- end
37
27
 
38
- # Retrieve a list of the stamps the user has collected
39
- #
40
- # @param [String] user_id (authenticated basic auth user) User ID (screen name)
41
- # @param [Integer] limit (20) limit per page
42
- # @return [Hashie::Mash] stamps info
43
- def stamps(user_id=self.username, limit=20)
44
- response = connection.get do |req|
45
- req.url "/users/#{user_id}/stamps", :limit => limit
46
- end
47
- response.body.stamps
48
- end
49
-
50
- # Retrieve a list of spots the user has visited most often
51
- #
52
- # @param [String] user_id (authenticated basic auth user) User ID (screen name)
53
- # @return [Hashie::Mash] item info
54
- def top_spots(user_id=self.username)
55
- connection.get("/users/#{user_id}/top_spots").body.top_spots
56
- end
57
-
58
- # Retrieve information about a specific trip
59
- #
60
- # @param [Integer] trip_id Trip ID
61
- # @return [Hashie::Mash] trip info
62
- def trip(trip_id)
63
- connection.get("/trips/#{trip_id}").body
64
- end
65
-
66
- # Retrieve information about a specific spot
67
- #
68
- # @param [Integer] spot_id Spot ID
69
- # @return [Hashie::Mash] Spot info
70
- def spot(spot_id)
71
- connection.get("/spots/#{spot_id}").body
72
- end
73
-
74
- # Retrieve a list of check-ins at a particular spot. Shows only the activity that is visible to a given user.
75
- #
76
- # @param [Integer] spot_id Spot ID
77
- # @return [Hashie::Mash] Spot info
78
- def spot_events(spot_id)
79
- connection.get("/spots/#{spot_id}/events").body.activity
80
- end
81
-
82
- # Retrieve a list of items available at a particular spot
83
- #
84
- # @param [Integer] spot_id Spot ID
85
- # @return [Hashie::Mash] Spot info
86
- def spot_items(spot_id)
87
- connection.get("/spots/#{spot_id}/items").body.items
88
- end
89
-
90
- # Retrieve a list of flags for a particular spot
91
- #
92
- # @param [Integer] spot_id Spot ID
93
- # @return [Hashie::Mash] Array of Flags
94
- def spot_flags(spot_id)
95
- connection.get("/spots/#{spot_id}/flags").body.flags
96
- end
97
-
98
- # Retrieve a list of flags
99
- #
100
- # @return [<Hashie::Mash>] Flag info
101
- def list_flags(options={})
102
- connection.get("/flags").body.flags
103
- end
104
-
105
- # Retrieve information about a particular flag
106
- #
107
- # @param [Integer] flag_id Flag ID
108
- # @return [Hashie::Mash] Flag info
109
- def flag(flag_id)
110
- connection.get("/flags/#{flag_id}").body
111
- end
112
-
113
- # Retrieve a list of spots within a specified distance of a location
114
- #
115
- # @option options [Float] :latitude Latitude of search location
116
- # @option options [Float] :longitude Longitude of search location
117
- # @option options [Integer] :radius Search radius (in meters)
118
- # @return [Hashie::Mash] spots info
119
- def list_spots(options={})
120
- query = format_geo_options(options)
121
- response = connection.get do |req|
122
- req.url "/spots", query
123
- end
124
- response.body.spots
125
- end
126
-
127
- # List of trips
128
- #
129
- # @return [<Hashie::Mash>] trip info
130
- def trips(options={})
131
- if user_id = options.delete(:user_id)
132
- options[:user_url] = "/users/#{user_id}"
133
- end
134
- query = format_geo_options(options)
135
- response = connection.get do |req|
136
- req.url "/trips", query
137
- end
138
- response.body.trips
139
- end
140
-
141
- # Lists all spot categories
142
- #
143
- # @return [<Hashie::Mash>] category info
144
- def categories
145
- connection.get("/categories").body.spot_categories
146
- end
147
-
148
- # Retrieve information about a specific category
149
- #
150
- # @param [Integer] id Category ID
151
- # @return [Hashie::Mash] category info
152
- def category(id)
153
- connection.get("/categories/#{id}").body
154
- end
155
-
156
- # Fetch info for a checkin
157
- #
158
- # @param [Integer] id Checkin ID
159
- # @return [Hashie::Mash] checkin info
160
- def checkin_info(id)
161
- connection.get("/checkins/#{id}").body
162
- end
163
-
164
- # Check in at a spot
165
- #
166
- # @option details [Integer] :spot_id Spot ID
167
- # @option details [Float] :lat Latitude of spot
168
- # @option details [Float] :lng Longitude of spot
169
- # @option details [String] :comment Checkin comment
170
- # @option details [Boolean] :post_to_twitter Post Checkin to Twitter
171
- # @option details [Boolean] :post_to_facebook Post Checkin to Facebook
172
- def checkin(details={})
173
- checkin_path = "/checkins"
174
- checkin_path += "/test" if Gowalla.test_mode?
175
- response = connection.post do |req|
176
- req.url checkin_path
177
- req.body = details
178
- end
179
- response.body
180
- end
181
-
182
28
  # Check for missing access token
183
29
  #
184
30
  # @return [Boolean] whether or not to redirect to get an access token
185
31
  def needs_access?
186
32
  @api_secret and @access_token.to_s == ''
187
33
  end
188
-
189
- # Raw HTTP connection, either Faraday::Connection
34
+
35
+ # Raw HTTP connection, either Faraday::Connection
190
36
  #
191
37
  # @return [Faraday::Connection]
192
38
  def connection
@@ -198,18 +44,18 @@ module Gowalla
198
44
  builder.use Faraday::Response::MultiJson
199
45
  builder.use Faraday::Response::Mashify
200
46
  end
201
-
47
+
202
48
  end
203
-
49
+
204
50
  # Provides raw access to the OAuth2 Client
205
51
  #
206
- # @return [OAuth2::Client]
52
+ # @return [OAuth2::Client]
207
53
  def oauth_client
208
54
  if @oauth_client
209
55
  @oauth_client
210
56
  else
211
57
  conn ||= Faraday::Connection.new \
212
- :url => "https://api.gowalla.com",
58
+ :url => "https://api.gowalla.com",
213
59
  :headers => default_headers
214
60
 
215
61
  oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {
@@ -223,7 +69,7 @@ module Gowalla
223
69
  end
224
70
 
225
71
  private
226
-
72
+
227
73
  # @private
228
74
  def format_geo_options(options={})
229
75
  options[:lat] = "+#{options[:lat]}" if options[:lat].to_i > 0
@@ -233,17 +79,17 @@ module Gowalla
233
79
  end
234
80
  options
235
81
  end
236
-
82
+
237
83
  # @private
238
84
  def default_headers
239
85
  headers = {
240
- :accept => 'application/json',
86
+ :accept => 'application/json',
241
87
  :user_agent => 'Ruby gem',
242
88
  'X-Gowalla-API-Key' => api_key
243
89
  }
244
90
  end
245
-
246
-
91
+
92
+
247
93
  end
248
-
94
+
249
95
  end