foursquared 0.0.4
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.
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/Gemfile +19 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +30 -0
- data/foursquared.gemspec +34 -0
- data/lib/core_ext/symbol.rb +7 -0
- data/lib/foursquared/badges.rb +12 -0
- data/lib/foursquared/checkins.rb +89 -0
- data/lib/foursquared/client.rb +58 -0
- data/lib/foursquared/error.rb +17 -0
- data/lib/foursquared/events.rb +18 -0
- data/lib/foursquared/lists.rb +97 -0
- data/lib/foursquared/oauth/client.rb +37 -0
- data/lib/foursquared/pages.rb +49 -0
- data/lib/foursquared/photos.rb +34 -0
- data/lib/foursquared/response/badge.rb +87 -0
- data/lib/foursquared/response/badge_group.rb +42 -0
- data/lib/foursquared/response/category.rb +53 -0
- data/lib/foursquared/response/checkin.rb +180 -0
- data/lib/foursquared/response/event.rb +52 -0
- data/lib/foursquared/response/list.rb +199 -0
- data/lib/foursquared/response/list_item.rb +63 -0
- data/lib/foursquared/response/photo.rb +102 -0
- data/lib/foursquared/response/special.rb +131 -0
- data/lib/foursquared/response/tip.rb +134 -0
- data/lib/foursquared/response/user.rb +246 -0
- data/lib/foursquared/response/venue.rb +252 -0
- data/lib/foursquared/settings.rb +28 -0
- data/lib/foursquared/specials.rb +25 -0
- data/lib/foursquared/tips.rb +113 -0
- data/lib/foursquared/users.rb +206 -0
- data/lib/foursquared/venues.rb +217 -0
- data/lib/foursquared/version.rb +4 -0
- data/lib/foursquared.rb +47 -0
- data/spec/foursquared/badges_spec.rb +82 -0
- data/spec/foursquared/checkins_spec.rb +0 -0
- data/spec/foursquared/events_spec.rb +50 -0
- data/spec/foursquared/oauth/client_spec.rb +24 -0
- data/spec/foursquared/pages_spec.rb +42 -0
- data/spec/foursquared/photos_spec.rb +41 -0
- data/spec/foursquared/response/badge_spec.rb +40 -0
- data/spec/foursquared/response/category_spec.rb +48 -0
- data/spec/foursquared/response/checkin_spec.rb +100 -0
- data/spec/foursquared/response/event_category_spec.rb +48 -0
- data/spec/foursquared/response/event_spec.rb +60 -0
- data/spec/foursquared/response/list_spec.rb +56 -0
- data/spec/foursquared/response/photo_spec.rb +70 -0
- data/spec/foursquared/response/special_spec.rb +0 -0
- data/spec/foursquared/response/user_spec.rb +124 -0
- data/spec/foursquared/response/venue_spec.rb +83 -0
- data/spec/foursquared/specials_spec.rb +4 -0
- data/spec/foursquared/users_spec.rb +241 -0
- data/spec/spec_helper.rb +27 -0
- metadata +344 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
# Foursquared module
|
2
|
+
module Foursquared
|
3
|
+
# Venues module
|
4
|
+
module Venues
|
5
|
+
|
6
|
+
# Venue detail
|
7
|
+
# @param [String] venue_id ID of venue to retrieve
|
8
|
+
# @return [Foursquared::Response::Venue]
|
9
|
+
def venue venue_id
|
10
|
+
response = get("/venues/#{venue_id}")["response"]
|
11
|
+
@venue = Foursquared::Response::Venue.new(self, response["venue"])
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add a venue
|
15
|
+
# @param [Hash] options
|
16
|
+
# @option options [String] :name required The name of the venue
|
17
|
+
# @option options [String] :address The address of the venue
|
18
|
+
# @option options [String] :crossStreet The nearest intersecting street or streets.
|
19
|
+
# @option options [String] :city The city name where this venue is.
|
20
|
+
# @option options [String] :state The nearest state or province to the venue.
|
21
|
+
# @option options [String] :zip The zip or postal code for the venue.
|
22
|
+
# @option options [String] :phone The phone number of the venue.
|
23
|
+
# @option options [String] :twitter The twitter handle of the venue.
|
24
|
+
# @option options [String] :ll required Latitude and longitude of the venue, as accurate as is known.
|
25
|
+
# @option options [String] :primaryCategoryId The ID of the category to which you want to assign this venue.
|
26
|
+
# @option options [String] :description A freeform description of the venue, up to 300 characters.
|
27
|
+
# @option options [String] :url The url of the homepage of the venue.
|
28
|
+
# @option options [Boolean] :ignoreDuplicates A boolean flag telling the server to ignore duplicates and force the addition of this venue.
|
29
|
+
# @option options [String] :ignoreDuplicatesKey Required if ignoreDuplicates is true. This key will be available in the response of the HTTP 409 error of the first (failed) attempt to add venue.
|
30
|
+
def add_venue options={}
|
31
|
+
response = post("/venues/add", options)["response"]
|
32
|
+
Foursquared::Response::Venue.new(self, response["venue"])
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns a hierarchical list of categories applied to venues.
|
36
|
+
# @return [Array<Foursquared::Response::Category>]
|
37
|
+
def venue_categories
|
38
|
+
response = get("/venues/categories")["response"]
|
39
|
+
response["categories"].collect{|category| Foursquared::Response::Category.new(self, category) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Explore Recommended and Popular Venues
|
43
|
+
# @param [Hash] options
|
44
|
+
# @option options [String] :ll required unless :near is provided. Latitude and longitude of the user's location.
|
45
|
+
# @option options [String] :near required unless :ll is provided. A string naming a place in the world
|
46
|
+
# @option options [String] :llAcc Accuracy of latitude and longitude, in meters.
|
47
|
+
# @option options [String] :alt Altitude of the user's location, in meters.
|
48
|
+
# @option options [String] :altAcc Accuracy of the user's altitude, in meters.
|
49
|
+
# @option options [String] :radius Radius to search within, in meters.
|
50
|
+
# @option options [String] :section One of food, drinks, coffee, shops, arts, outdoors, sights, trending or specials, nextVenues or topPicks
|
51
|
+
# @option options [String] :query A term to be searched against a venue's tips, category, etc.
|
52
|
+
# @option options [Integer] :limit Number of results to return, up to 50.
|
53
|
+
# @option options [Integer] :offset Used to page through results.
|
54
|
+
# @option options [String] :novelty Pass new or old to limit results to places the acting user hasn't been or has been, respectively.
|
55
|
+
# @option options [String] :friendVisits Pass visited or notvisited to limit results to places the acting user's friends have or haven't been, respectively.
|
56
|
+
# @option options [String] :venuePhotos Boolean flag to include a photo in the response for each venue, if one is available (1/0)
|
57
|
+
# @option options [String] :lastVenue A venue ID to use in combination with the intent=nextVenues parameter, which returns venues users often visit after a given venue.
|
58
|
+
def explore_venues options={}
|
59
|
+
response = get("/venues/explore", options)["response"]
|
60
|
+
response["groups"].each do |group|
|
61
|
+
response["items"].each do |item|
|
62
|
+
item["venue"] = Foursquared::Response::Venue.new(self, item["venue"])
|
63
|
+
item["tips"].map!{|tip| Foursquared::Response::List.new(self, tip)}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
response
|
67
|
+
end
|
68
|
+
|
69
|
+
# Get a list of venues the current user manages.
|
70
|
+
# @return [Array<Foursquared::Response::Venue>] An array of compact venues the user manages.
|
71
|
+
def managed_venues
|
72
|
+
response = get("/venues/managed")["response"]
|
73
|
+
@venues = response["venues"].collect{|venue| Foursquared::Response::Venue.new(self, venue)}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns a list of venues near the current location, optionally matching a search term.
|
77
|
+
# @param [Hash] options
|
78
|
+
# @option options [String] :ll required unless :near is provided. Latitude and longitude of the user's location.
|
79
|
+
# @option options [String] :near required unless :ll is provided. A string naming a place in the world
|
80
|
+
# @option options [String] :llAcc Accuracy of latitude and longitude, in meters.
|
81
|
+
# @option options [String] :alt Altitude of the user's location, in meters.
|
82
|
+
# @option options [String] :altAcc Accuracy of the user's altitude, in meters.
|
83
|
+
# @option options [String] :radius Radius to search within, in meters.
|
84
|
+
# @option options [String] :query A search term to be applied against venue names.
|
85
|
+
# @option options [Integer] :limit Number of results to return, up to 50.
|
86
|
+
# @option options [String] :intent Checkout https://developer.foursquare.com/docs/venues/search for the possible values
|
87
|
+
# @option options [String] :sw Checkout https://developer.foursquare.com/docs/venues/search for details
|
88
|
+
# @option options [String] :ne Checkout https://developer.foursquare.com/docs/venues/search for details
|
89
|
+
# @option options [String] :categoryId A comma separated list of categories to limit results to
|
90
|
+
# @option options [String] :url A third-party URL which we will attempt to match against our map of venues to URLs
|
91
|
+
# @option options [String] :providerId Identifier for a known third party that is part of our map of venues to URLs
|
92
|
+
# @option options [String] :linkedId Identifier used by third party specified in providerId, which we will attempt to match against our map of venues to URLs
|
93
|
+
# @return [Array] An array of compact venues.
|
94
|
+
def search_venues options={}
|
95
|
+
response = get("/venues/search", options)["response"]
|
96
|
+
@venues = response["venues"].collect{|venue| Foursquared::Response::Venue.new(self, venue)}
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns a list of venues near the current location with the most people currently checked in.
|
100
|
+
# @param [Hash] options
|
101
|
+
# @option options [String] :ll required Latitude and longitude of the user's location.
|
102
|
+
# @option options [Integer] :limit Number of results to return, up to 50.
|
103
|
+
# @option options [Integer] :radius Radius in meters, up to approximately 2000 meters.
|
104
|
+
# @return [Array] An array of venues that are currently trending, with their hereNow populated.
|
105
|
+
def trending_venues options={}
|
106
|
+
response = get("/venues/trending", options)["response"]
|
107
|
+
@venues = response["venues"].collect{|venue| Foursquared::Response::Venue.new(self, venue)}
|
108
|
+
end
|
109
|
+
|
110
|
+
# Gives information about the current events at a place.
|
111
|
+
# @param [String] venue_id required The venue id for which events are being requested.
|
112
|
+
# @return [Hash] A count and items of event items. Also includes a "summary" string describing the set of events at the venue.
|
113
|
+
def venue_events venue_id
|
114
|
+
response = get("/venues/#{venue_id}/events")["response"]
|
115
|
+
@events = response["events"]
|
116
|
+
@events["items"].map!{|item| Foursquared::Response::Event.new(self, item)}
|
117
|
+
@events
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns hours for a venue.
|
121
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
122
|
+
# @return [Array] An array of timeframes of hours.
|
123
|
+
def venue_hours venue_id
|
124
|
+
response = get("/venues/#{venue_id}/hours")["response"]["hours"]
|
125
|
+
end
|
126
|
+
|
127
|
+
# Users who have liked a venue
|
128
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
129
|
+
# @return [Hash] A count and groups of users who like this venue
|
130
|
+
def venue_likes venue_id
|
131
|
+
response = get("/venues/#{venue_id}/likes")["response"]["likes"]
|
132
|
+
response["groups"].each do |group|
|
133
|
+
response["items"].map!{|item| Foursquared::Response::User.new(self, item)}
|
134
|
+
end
|
135
|
+
response
|
136
|
+
end
|
137
|
+
|
138
|
+
# The lists that this venue appears on.
|
139
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
140
|
+
# @param [Hash] options
|
141
|
+
# @option options [String] :group Can be created, edited, followed, friends, other.
|
142
|
+
# @option options [Integer] :limit Number of results to return, up to 200.
|
143
|
+
# @option options [Integer] :offset Used to page through results. Must specify a group
|
144
|
+
# @return [Hash]
|
145
|
+
def venue_lists venue_id, options={}
|
146
|
+
response = get("/venues/#{venue_id}/lists", options)["response"]["lists"]
|
147
|
+
if response["groups"]
|
148
|
+
response["groups"].each do |group|
|
149
|
+
group["items"].map!{|item| Foursquared::Response::Lists.new(self, item)} if group["items"]
|
150
|
+
end
|
151
|
+
else
|
152
|
+
response["items"].map!{|item| Foursquared::Response::Lists.new(self, item)}
|
153
|
+
end
|
154
|
+
response
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns photos for a venue.
|
158
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
159
|
+
# @param [Hash] options
|
160
|
+
# @option options [String] :group required Pass checkin for photos added by friends (including on their recent checkins). Pass venue for public photos added to the venue by non-friends. Use multi to fetch both.
|
161
|
+
# @option options [Integer] :limit Number of results to return, up to 200.
|
162
|
+
# @option options [Integer] :offset Used to page through results
|
163
|
+
# @return [Hash] A count and items of photos
|
164
|
+
def venue_photos venue_id, options={}
|
165
|
+
response = get("/venues/#{venue_id}/photos", options)["response"]["photos"]
|
166
|
+
response["items"].map!{|item| Foursquared::Response::Photo.new(self, item)}
|
167
|
+
response
|
168
|
+
end
|
169
|
+
|
170
|
+
# Returns a list of venues similar to the specified venue.
|
171
|
+
# @param [String] venue_id required The venue you want similar venues for.
|
172
|
+
# @return [Hash] A count and items of similar venues.
|
173
|
+
def venue_likes venue_id
|
174
|
+
response = get("/venues/#{venue_id}/similar")["response"]["similarVenues"]
|
175
|
+
response["items"].map!{|item| Foursquared::Response::Venue.new(self, item)}
|
176
|
+
response
|
177
|
+
end
|
178
|
+
|
179
|
+
# Flag a Venue
|
180
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
181
|
+
# @param [Hash] options
|
182
|
+
# @option options [String] :problem required One of mislocated, closed, duplicate, inappropriate, doesnt_exist, event_over
|
183
|
+
# @option options [String] :venueId ID of the duplicated venue (for problem duplicate)
|
184
|
+
def flag_venue venue_id, options={}
|
185
|
+
response = post("/venues/#{venue_id}/flag", options)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Like or unlike a venue
|
189
|
+
# @param [String] venue_id required The venue id for which hours are being requested.
|
190
|
+
# @param [Hash] options
|
191
|
+
# @option options [Integer] :set If 1, like this venue. If 0 unlike (un-do a previous like) it. Default value is 1.
|
192
|
+
# @return [Hash] Updated count and groups of users who like this venue
|
193
|
+
def like_venue venue_id, options={}
|
194
|
+
response = post("/venues/#{venue_id}/like", options)["response"]["likes"]
|
195
|
+
response["groups"].each do |group|
|
196
|
+
response["items"].map!{|item| Foursquared::Response::User.new(self, item)}
|
197
|
+
end
|
198
|
+
response
|
199
|
+
end
|
200
|
+
|
201
|
+
# Propose an Edit to a Venue
|
202
|
+
# @param [Hash] options
|
203
|
+
# @option options [String] :name The name of the venue
|
204
|
+
# @option options [String] :address The address of the venue
|
205
|
+
# @option options [String] :crossStreet The nearest intersecting street or streets.
|
206
|
+
# @option options [String] :city The city name where this venue is.
|
207
|
+
# @option options [String] :state The nearest state or province to the venue.
|
208
|
+
# @option options [String] :zip The zip or postal code for the venue.
|
209
|
+
# @option options [String] :phone The phone number of the venue.
|
210
|
+
# @option options [String] :ll Latitude and longitude of the venue, as accurate as is known.
|
211
|
+
# @option options [String] :primaryCategoryId The ID of the category to which you want to assign this venue.
|
212
|
+
# @option options [String] :hours The hours for the venue, as a semi-colon separated list of open segments and named segments
|
213
|
+
def propose_venue_edit venue_id, options={}
|
214
|
+
response = post("/venues/#{venue_id}", options)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
data/lib/foursquared.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'httmultiparty'
|
2
|
+
require 'json'
|
3
|
+
directory = File.expand_path(File.dirname(__FILE__))
|
4
|
+
require 'core_ext/symbol'
|
5
|
+
module Foursquared
|
6
|
+
class << self
|
7
|
+
|
8
|
+
|
9
|
+
attr_accessor :client_id, :client_secret, :api_version, :ssl, :access_token, :locale
|
10
|
+
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield self
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# require 'foursquare2/campaigns'
|
19
|
+
require 'foursquared/users'
|
20
|
+
require 'foursquared/photos'
|
21
|
+
require 'foursquared/lists'
|
22
|
+
require 'foursquared/checkins'
|
23
|
+
require 'foursquared/venues'
|
24
|
+
require 'foursquared/badges'
|
25
|
+
require 'foursquared/events'
|
26
|
+
require 'foursquared/pages'
|
27
|
+
require 'foursquared/specials'
|
28
|
+
require 'foursquared/tips'
|
29
|
+
require 'foursquared/oauth/client'
|
30
|
+
require 'foursquared/client'
|
31
|
+
require 'foursquared/response/user'
|
32
|
+
require 'foursquared/response/list'
|
33
|
+
require 'foursquared/response/list_item'
|
34
|
+
require 'foursquared/response/photo'
|
35
|
+
require 'foursquared/response/venue'
|
36
|
+
require 'foursquared/response/checkin'
|
37
|
+
require 'foursquared/response/badge'
|
38
|
+
require 'foursquared/response/badge_group'
|
39
|
+
require 'foursquared/response/event'
|
40
|
+
require 'foursquared/response/category'
|
41
|
+
require 'foursquared/response/special'
|
42
|
+
require 'foursquared/response/tip'
|
43
|
+
require 'foursquared/error'
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
include Foursquared::Response
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/badges'
|
3
|
+
|
4
|
+
describe Foursquared::Badges do
|
5
|
+
|
6
|
+
let(:user_badges) do
|
7
|
+
YAML.load(%{
|
8
|
+
meta:
|
9
|
+
code: 200
|
10
|
+
response:
|
11
|
+
sets:
|
12
|
+
groups:
|
13
|
+
- type: "all"
|
14
|
+
name: "All Badges"
|
15
|
+
image:
|
16
|
+
prefix: "https://foursquare.com/img/badge/"
|
17
|
+
sizes:
|
18
|
+
- 24
|
19
|
+
- 32
|
20
|
+
name: "/allbadges.png"
|
21
|
+
items:
|
22
|
+
- "508b859de4b01167eaad0476"
|
23
|
+
- "5066d689e4b0ca8b1f1c1804"
|
24
|
+
badges:
|
25
|
+
4f7a7d3ae4b02f1b2c869efb:
|
26
|
+
id: "4f7a7d3ae4b02f1b2c869efb"
|
27
|
+
badgeId: "4c4f08667a0803bbaa202ab7"
|
28
|
+
defaultSetType: "foursquare"
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:badge) do
|
34
|
+
YAML.load(%{
|
35
|
+
meta:
|
36
|
+
code: 200
|
37
|
+
response:
|
38
|
+
badge:
|
39
|
+
id: "4f7a7d3ae4b02f1b2c869efb"
|
40
|
+
badgeId: "4c4f08667a0803bbaa202ab7"
|
41
|
+
name: "Newbie"
|
42
|
+
unlockMessage: "You unlocked the Newbie badge!"
|
43
|
+
description: "Your first check-in!"
|
44
|
+
badgeText: "Your first check-in!"
|
45
|
+
image:
|
46
|
+
prefix: "https://playfoursquare.s3.amazonaws.com/badge/"
|
47
|
+
sizes:
|
48
|
+
- 57
|
49
|
+
114
|
50
|
+
name: "/newbie.png"
|
51
|
+
unlocks:
|
52
|
+
- checkins:
|
53
|
+
- id: "4f7a7d3ae4b02f1b2c869eef"
|
54
|
+
}
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
subject { foursquared_test_client }
|
59
|
+
|
60
|
+
before(:each) do
|
61
|
+
stub_request(:get, "https://api.foursquare.com/v2/users/self/badges?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => user_badges.to_json, :headers => {})
|
62
|
+
stub_request(:get, "https://api.foursquare.com/v2/badges/4f7a7d3ae4b02f1b2c869efb?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
|
63
|
+
to_return(:status => 200, :body => badge.to_json, :headers => {})
|
64
|
+
@user_badges = subject.user_badges("self")
|
65
|
+
end
|
66
|
+
describe "#user_badges" do
|
67
|
+
describe "sets" do
|
68
|
+
it "should give the sets of badge types" do
|
69
|
+
@user_badges["sets"]["groups"].should each { |group|
|
70
|
+
group.should be_a(Foursquared::Response::BadgeGroup)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
describe "badges" do
|
75
|
+
it "should give the badges' details" do
|
76
|
+
@user_badges["badges"].keys.should each {|badge_id|
|
77
|
+
@user_badges["badges"][badge_id].should be_a(Foursquared::Response::Badge)
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/events'
|
3
|
+
|
4
|
+
describe Foursquared::Events do
|
5
|
+
let(:event) do
|
6
|
+
YAML.load(%{
|
7
|
+
meta:
|
8
|
+
code: 200
|
9
|
+
response:
|
10
|
+
event:
|
11
|
+
venueId: "40afe980f964a5203bf31ee3"
|
12
|
+
id: "5093492991d4a3bd84c82646"
|
13
|
+
name: "Skyfall: The IMAX Experience"
|
14
|
+
foreignIds:
|
15
|
+
count: 1
|
16
|
+
items:
|
17
|
+
- domain: "fandango.com"
|
18
|
+
id: "5826-153164"
|
19
|
+
hereNow:
|
20
|
+
count: 0
|
21
|
+
groups:
|
22
|
+
- type: "friends"
|
23
|
+
name: "Friends here"
|
24
|
+
count: 0
|
25
|
+
items: []
|
26
|
+
- type: "others"
|
27
|
+
name: "Other people here"
|
28
|
+
count: 0
|
29
|
+
items: []
|
30
|
+
allDay: true
|
31
|
+
date: 1355115600
|
32
|
+
timeZone: "America/New_York"
|
33
|
+
stats:
|
34
|
+
checkinsCount: 9
|
35
|
+
usersCount: 9
|
36
|
+
url: "https://foursquare.com/events/movies?theater=AAORE&movie=153164&wired=true"
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
subject { foursquared_test_client }
|
41
|
+
|
42
|
+
before :each do
|
43
|
+
stub_request(:get, "https://api.foursquare.com/v2/events/5093492991d4a3bd84c82646?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => event.to_json, :headers => {})
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return the event with the given id" do
|
47
|
+
subject.event("5093492991d4a3bd84c82646").should be_a Foursquared::Response::Event
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/oauth/client'
|
3
|
+
require 'pp'
|
4
|
+
require 'httparty'
|
5
|
+
describe Foursquared::OAuth::Client do
|
6
|
+
before :each do
|
7
|
+
@client = Foursquared::OAuth::Client.new("abc", "S2TJO3KFFXZSXS44WKVGWGKH204U455MI3P0JUV0ADTWRORZ","http://localhost")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#authorize_url" do
|
11
|
+
it "includes the client_id" do
|
12
|
+
expect(@client.authorize_url).to include('client_id=abc')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "includes the type" do
|
16
|
+
expect(@client.authorize_url).to include('response_type=code')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "includes the redirect_uri" do
|
20
|
+
cb = 'http://localhost'
|
21
|
+
expect(@client.authorize_url).to include("redirect_uri=#{Rack::Utils.escape(cb)}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/pages'
|
3
|
+
|
4
|
+
describe Foursquared::Pages do
|
5
|
+
|
6
|
+
let(:page) do
|
7
|
+
YAML.load(%{
|
8
|
+
meta:
|
9
|
+
code: 200
|
10
|
+
response:
|
11
|
+
user:
|
12
|
+
id: "1070527"
|
13
|
+
firstName: "Starbucks"
|
14
|
+
type: "chain"
|
15
|
+
followers:
|
16
|
+
groups:
|
17
|
+
- type: "friends"
|
18
|
+
name: "Liked by 2 friends"
|
19
|
+
items:
|
20
|
+
- id: "36332988"
|
21
|
+
firstName: "Sree"
|
22
|
+
lastName: "Ram"
|
23
|
+
relationship: "friend"
|
24
|
+
- id: "38283243"
|
25
|
+
firstName: "Vineeth"
|
26
|
+
lastName: "Nix"
|
27
|
+
relationship: "friend"
|
28
|
+
}
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
subject { foursquared_test_client }
|
33
|
+
|
34
|
+
before :each do
|
35
|
+
stub_request(:get, "https://api.foursquare.com/v2/pages/1070527?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:body => page.to_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the page with the id" do
|
39
|
+
subject.page(1070527).should be_a(Foursquared::Response::User)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/response/user'
|
3
|
+
require 'foursquared/response/photo'
|
4
|
+
require 'foursquared/client'
|
5
|
+
require 'foursquared/photos'
|
6
|
+
|
7
|
+
describe Foursquared::Photos do
|
8
|
+
let(:photo) do
|
9
|
+
YAML.load(%{
|
10
|
+
meta:
|
11
|
+
code: 200
|
12
|
+
response:
|
13
|
+
photo:
|
14
|
+
id: "4d0fb8162d39a340637dc42b"
|
15
|
+
createdAt: 1292875798
|
16
|
+
source:
|
17
|
+
name: "foursquare for iPhone"
|
18
|
+
url: "https://foursquare.com/download/#/iphone"
|
19
|
+
prefix: "https://irs0.4sqi.net/img/general/"
|
20
|
+
suffix: "/UYU54GYOCURPAUYXH5V2U3EOM4DCX4VZPT3YOMN43H555KU2.jpg"
|
21
|
+
width: 540
|
22
|
+
height: 720
|
23
|
+
user:
|
24
|
+
id: "2102"
|
25
|
+
firstName: "Kushal"
|
26
|
+
lastName: "D."
|
27
|
+
photo:
|
28
|
+
prefix: "https://irs1.4sqi.net/img/user/"
|
29
|
+
suffix: "/2102_1242573242.jpg"
|
30
|
+
visibility: "public"
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
before :each do
|
36
|
+
stub_request(:get, "https://api.foursquare.com/v2/photos/12345?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").
|
37
|
+
to_return(:status => 200, :body => photo.to_json, :headers => {})
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/response/badge'
|
3
|
+
|
4
|
+
describe Foursquared::Response::Badge do
|
5
|
+
|
6
|
+
let(:badge) do
|
7
|
+
YAML.load(%{
|
8
|
+
meta:
|
9
|
+
code: 200
|
10
|
+
response:
|
11
|
+
badge:
|
12
|
+
id: "4f7a7d3ae4b02f1b2c869efb"
|
13
|
+
badgeId: "4c4f08667a0803bbaa202ab7"
|
14
|
+
name: "Newbie"
|
15
|
+
unlockMessage: "You unlocked the Newbie badge!"
|
16
|
+
description: "Your first check-in!"
|
17
|
+
badgeText: "Your first check-in!"
|
18
|
+
image:
|
19
|
+
prefix: "https://playfoursquare.s3.amazonaws.com/badge/"
|
20
|
+
sizes:
|
21
|
+
- 57
|
22
|
+
114
|
23
|
+
name: "/newbie.png"
|
24
|
+
unlocks:
|
25
|
+
- checkins:
|
26
|
+
- id: "4f7a7d3ae4b02f1b2c869eef"
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
subject {foursquared_test_client.badge("4f7a7d3ae4b02f1b2c869efb")}
|
31
|
+
|
32
|
+
before :each do
|
33
|
+
stub_request(:get, "https://api.foursquare.com/v2/badges/4f7a7d3ae4b02f1b2c869efb?oauth_token=TestToken&v=#{Time.now.strftime("%Y%m%d")}").to_return(:status => 200, :body => badge.to_json, :headers => {})
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the badge's id" do
|
37
|
+
subject.id.should == "4f7a7d3ae4b02f1b2c869efb"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'foursquared/response/category'
|
3
|
+
|
4
|
+
describe Foursquared::Response::Category do
|
5
|
+
|
6
|
+
let(:event_category) do
|
7
|
+
YAML.load(%{
|
8
|
+
id: "4dfb90c6bd413dd705e8f897"
|
9
|
+
name: "Movies"
|
10
|
+
pluralName: "Movies"
|
11
|
+
shortName: "Movie"
|
12
|
+
icon:
|
13
|
+
prefix: "https://foursquare.com/img/categories_v2/arts_entertainment/movietheater_"
|
14
|
+
suffix: ".png"
|
15
|
+
categories:
|
16
|
+
- id: "4e132f48bd41026cd50e8f8e"
|
17
|
+
name: "Baseball Games"
|
18
|
+
pluralName: "Baseball Games"
|
19
|
+
shortName: "Baseball"
|
20
|
+
icon:
|
21
|
+
prefix: "https://foursquare.com/img/categories_v2/arts_entertainment/stadium_baseball_"
|
22
|
+
suffix: ".png"
|
23
|
+
categories: []
|
24
|
+
}
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
subject {Foursquared::Response::Category.new(event_category)}
|
29
|
+
|
30
|
+
describe "#icon" do
|
31
|
+
it "should have prefix, suffix and urls" do
|
32
|
+
subject.icon.keys.should ~ ["urls", "prefix", "suffix", ]
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "urls" do
|
36
|
+
it "should have urls for 32x32, 64x64 and 256x256 icons" do
|
37
|
+
subject.icon["urls"].keys.should ~ ["32x32", "64x64", "256x256"]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should give the sub categories of the category" do
|
44
|
+
subject.categories.should each { |category|
|
45
|
+
category.should be_a(Foursquared::Response::Category)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|