foursquare2 1.9.5 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.5
1
+ 1.9.6
data/foursquare2.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "foursquare2"
8
- s.version = "1.9.5"
8
+ s.version = "1.9.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Mueller", "Marco Moura"]
12
- s.date = "2013-03-09"
12
+ s.date = "2013-04-14"
13
13
  s.description = "Gives access to all endpoints in version 2 of foursquare's API with syntax that will be familiar to those who used the original foursquare gem by Jeremy Welch."
14
14
  s.email = ["muellermr@gmail.com", "email@marcomoura.com"]
15
15
  s.extra_rdoc_files = [
@@ -37,8 +37,10 @@ Gem::Specification.new do |s|
37
37
  "lib/foursquare2/specials.rb",
38
38
  "lib/foursquare2/tips.rb",
39
39
  "lib/foursquare2/users.rb",
40
+ "lib/foursquare2/venuegroups.rb",
40
41
  "lib/foursquare2/venues.rb",
41
42
  "test/config.rb",
43
+ "test/fixtures/campaigns/campaign.json",
42
44
  "test/fixtures/campaigns/campaign_created.json",
43
45
  "test/fixtures/campaigns/campaigns_list.json",
44
46
  "test/fixtures/checkins/checkin.json",
@@ -76,6 +78,9 @@ Gem::Specification.new do |s|
76
78
  "test/fixtures/users/user_tips.json",
77
79
  "test/fixtures/users/user_venuestats.json",
78
80
  "test/fixtures/users/user_venuestats_friend_id.json",
81
+ "test/fixtures/venuegroups/venuegroup.json",
82
+ "test/fixtures/venuegroups/venuegroup_add.json",
83
+ "test/fixtures/venuegroups/venuegroup_update.json",
79
84
  "test/fixtures/venues/explore_venues.json",
80
85
  "test/fixtures/venues/managed_venues.json",
81
86
  "test/fixtures/venues/no_venues_by_tip.json",
@@ -85,6 +90,7 @@ Gem::Specification.new do |s|
85
90
  "test/fixtures/venues/trending_venues.json",
86
91
  "test/fixtures/venues/venue.json",
87
92
  "test/fixtures/venues/venue_herenow.json",
93
+ "test/fixtures/venues/venue_hours.json",
88
94
  "test/fixtures/venues/venue_links.json",
89
95
  "test/fixtures/venues/venue_menus.json",
90
96
  "test/fixtures/venues/venue_photos.json",
@@ -101,6 +107,7 @@ Gem::Specification.new do |s|
101
107
  "test/test_specials.rb",
102
108
  "test/test_tips.rb",
103
109
  "test/test_users.rb",
110
+ "test/test_venuegroups.rb",
104
111
  "test/test_venues.rb"
105
112
  ]
106
113
  s.homepage = "http://github.com/mattmueller/foursquare2"
data/lib/foursquare2.rb CHANGED
@@ -35,6 +35,7 @@ module Foursquare2
35
35
  require 'foursquare2/tips'
36
36
  require 'foursquare2/checkins'
37
37
  require 'foursquare2/venues'
38
+ require 'foursquare2/venuegroups'
38
39
  require 'foursquare2/pages'
39
40
  require 'foursquare2/lists'
40
41
  require 'foursquare2/events'
@@ -1,5 +1,13 @@
1
1
  module Foursquare2
2
2
  module Campaigns
3
+
4
+ # Retrieve information about a campaign
5
+ #
6
+ # param [String] campaign_id The ID of the venue
7
+ def campaign(campaign_id)
8
+ response = connection.get("campaigns/#{campaign_id}")
9
+ return_error_or_body(response, response.body.response.campaign)
10
+ end
3
11
 
4
12
  # Add a campaign
5
13
  # Details on param options can be found at https://developer.foursquare.com/docs/campaigns/add
@@ -12,6 +12,7 @@ module Foursquare2
12
12
  extend Forwardable
13
13
 
14
14
  include Venues
15
+ include Venuegroups
15
16
  include Checkins
16
17
  include Tips
17
18
  include Photos
@@ -0,0 +1,61 @@
1
+ module Foursquare2
2
+ module Venuegroups
3
+
4
+ # Retrieve information about a venuegroup
5
+ #
6
+ # param [String] group_id The ID of the venuegroup
7
+
8
+ def venuegroup(group_id)
9
+ response = connection.get("venuegroups/#{group_id}")
10
+ return_error_or_body(response, response.body.response.venueGroup)
11
+ end
12
+
13
+ # Create a venue group. If the venueId parameter is specified,
14
+ # then the endpoint will add the specified venues to the venue group.
15
+ # If it is not possible to add all of the specified venues to the group,
16
+ # then creation of the venue group will fail entirely.
17
+ # @param [Hash] options
18
+ # @option options String :name - Required. The name to give the group.
19
+ # @option options String :venueId - Comma-delimited list of venue IDs to add to the group. If this parameter is not specified, then the venue group will initially be empty.
20
+
21
+ def add_venuegroup(options={})
22
+ response = connection.post do |req|
23
+ req.url "venuegroups/add", options
24
+ end
25
+ return_error_or_body(response, response.body.response.venueGroup)
26
+ end
27
+
28
+ # Updates a venue group. At least one of the name and venueId parameters must be specified.
29
+ # @param [String] group_id - required The ID of the venue group to modify
30
+ # @param [Hash] options
31
+ # @option options String :name - If specified, the new name to give to the group.
32
+ # @option options String :venueId - If specified, a comma-delimited list of venue IDs that will become the new set of venue IDs for the group.
33
+
34
+
35
+ def venuegroup_update(group_id, options={})
36
+ response = connection.post do |req|
37
+ req.url "venuegroups/#{group_id}/update", options
38
+ end
39
+ return_error_or_body(response, response.body.response.venueGroup)
40
+ end
41
+
42
+ # List all venue groups owned by the user.
43
+
44
+ def list_venuegroup
45
+ response = connection.get do |req|
46
+ req.url "venuegroups/list"
47
+ end
48
+ return_error_or_body(response, response.body.response.venueGroups)
49
+ end
50
+
51
+ # Delete a venue group.
52
+ # param [String] group_id - The ID of the venuegroup to delete.
53
+
54
+ def delete_venuegroup(group_id)
55
+ response = connection.post do |req|
56
+ req.url "venuegroups/#{group_id}/delete"
57
+ end
58
+ return_error_or_body(response, response.body.response)
59
+ end
60
+ end
61
+ end
@@ -246,5 +246,14 @@ module Foursquare2
246
246
  end
247
247
  return_error_or_body(response, response.body.response)
248
248
  end
249
+
250
+ # Get venue hours information.
251
+ #
252
+ # param [String] venue_id The ID of the venue
253
+
254
+ def venue_hours(venue_id)
255
+ response = connection.get("venues/#{venue_id}/hours")
256
+ return_error_or_body(response, response.body.response)
257
+ end
249
258
  end
250
259
  end
@@ -0,0 +1,33 @@
1
+ {
2
+ "meta": {"code": 200},
3
+ "response": {
4
+ "campaign": {
5
+ "id": "4e0deba2922e6f94b1410b79",
6
+ "venues": {
7
+ "count": 1,
8
+ "items": [
9
+ {
10
+ "id": "4e0deab3922e6f94b1410af3"
11
+ }
12
+ ]
13
+ },
14
+ "startsAt": 1309535356,
15
+ "startable": false,
16
+ "deleteable": false,
17
+ "requiresCodes": false,
18
+ "uploadInProgress": false,
19
+ "status": "active",
20
+ "special": {
21
+ "id": "4e0debea922e6f94b1410bb7",
22
+ "name": "Friends Special 7/1/2011",
23
+ "title": "Friends Special",
24
+ "text": "Check in with 2 friends and receive a free cowsy dungy clock!"
25
+ },
26
+ "timeZoneOffset": -240,
27
+ "venueGroups": {
28
+ "count": 0,
29
+ "items": [ ]
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "meta": {"code": 200},
3
+ "response": {
4
+ "venueGroup": {
5
+ "id": "4e15cd13b61c42e7c54e5bb6",
6
+ "name": "Venues",
7
+ "venues": {
8
+ "count": 1,
9
+ "items": [
10
+ {
11
+ "id": "4b8c3d87f964a520f7c532e3"
12
+ }
13
+ ]
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "meta": {"code": 200},
3
+ "response": {
4
+ "venueGroup": {
5
+ "id": "4e15cd13b61c42e7c54e5bb6",
6
+ "name": "Venues",
7
+ "venues": {
8
+ "count": 1,
9
+ "items": [
10
+ {
11
+ "id": "4b8c3d87f964a520f7c532e3"
12
+ }
13
+ ]
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "meta": {"code": 200},
3
+ "response": {
4
+ "venuegroup": {
5
+ "id": "4e15cd13b61c42e7c54e5bb6",
6
+ "name": "Venues",
7
+ "venues": {
8
+ "count": 2,
9
+ "items": [
10
+ {
11
+ "id": "4b8c3d87f964a520f7c532e3"
12
+ },
13
+ {
14
+ "id": "4d572bcc9e508cfab975189b"
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ {"meta":{"code":200},"notifications":[{"type":"notificationTray","item":{"unreadCount":0}}],"response":{"hours":{"timeframes":[{"days":[1,2,3,4,5,6],"includesToday":true,"open":[{"start":"0700","end":"1900"}],"segments":[]},{"days":[7],"open":[{"start":"0800","end":"1800"}],"segments":[]}]},"popular":{"timeframes":[{"days":[3],"includesToday":true,"open":[{"start":"0600","end":"1500"}],"segments":[]},{"days":[4],"open":[{"start":"0600","end":"1600"}],"segments":[]},{"days":[5],"open":[{"start":"0600","end":"1700"}],"segments":[]},{"days":[6],"open":[{"start":"0700","end":"1700"}],"segments":[]},{"days":[7],"open":[{"start":"0800","end":"1600"}],"segments":[]},{"days":[1],"open":[{"start":"0700","end":"1600"}],"segments":[]},{"days":[2],"open":[{"start":"0700","end":"1500"}],"segments":[]}]}}}
@@ -8,6 +8,12 @@ class TestCampaigns < Test::Unit::TestCase
8
8
  setup do
9
9
  @client = foursquare_test_client
10
10
  end
11
+
12
+ should "get a campaign" do
13
+ stub_get("https://api.foursquare.com/v2/campaigns/4e0deba2922e6f94b1410b79?oauth_token=#{@client.oauth_token}", "campaigns/campaign.json")
14
+ campaign = @client.campaign('4e0deba2922e6f94b1410b79')
15
+ campaign.id == "4e0deba2922e6f94b1410b79"
16
+ end
11
17
 
12
18
  should "add a campaign" do
13
19
  stub_post("https://api.foursquare.com/v2/campaigns/add?oauth_token=#{@client.oauth_token}&specialId=4bd876f886ba62b58a6e88b3", "campaigns/campaign_created.json")
@@ -0,0 +1,29 @@
1
+ require 'helper'
2
+
3
+ class TestVenuegroups < Test::Unit::TestCase
4
+
5
+ context "When using the foursquare API and working with venuegroups" do
6
+ setup do
7
+ @client = foursquare_test_client
8
+ end
9
+
10
+ should "get a venuegroup" do
11
+ stub_get("https://api.foursquare.com/v2/venuegroups/4e15cd13b61c42e7c54e5bb6?oauth_token=#{@client.oauth_token}", "venuegroups/venuegroup.json")
12
+ venuegroup = @client.venuegroup('4e15cd13b61c42e7c54e5bb6')
13
+ venuegroup.id == "4e15cd13b61c42e7c54e5bb6"
14
+ end
15
+
16
+ should "add a venuegroup" do
17
+ stub_post("https://api.foursquare.com/v2/venuegroups/add?oauth_token=#{@client.oauth_token}&name=Venues&venueId=4b8c3d87f964a520f7c532e3", "venuegroups/venuegroup_add.json")
18
+ venuegroup = @client.add_venuegroup(:name => 'Venues', :venueId => '4b8c3d87f964a520f7c532e3')
19
+ venuegroup.name == "Venues"
20
+ end
21
+
22
+ should "update a venuegroup" do
23
+ stub_post("https://api.foursquare.com/v2/venuegroups/4e15cd13b61c42e7c54e5bb6/update?oauth_token=#{@client.oauth_token}?venueId=4b8c3d87f964a520f7c532e3,4d572bcc9e508cfab975189b", "venuegroups/venuegroup_update.json")
24
+ venuegroup = @client.venuegroup('4e15cd13b61c42e7c54e5bb6')
25
+ venuegroup.venues.count == 2
26
+ end
27
+
28
+ end
29
+ end
data/test/test_venues.rb CHANGED
@@ -132,6 +132,12 @@ class TestVenues < Test::Unit::TestCase
132
132
  response.stats.totalCheckins.should == 1
133
133
  end
134
134
 
135
+ should "get hours from a venue" do
136
+ stub_get("https://api.foursquare.com/v2/venues/49d68c61f964a520e65c1fe3/hours?oauth_token=#{@client.oauth_token}", "venues/venue_hours.json")
137
+ response = @client.venue_hours('49d68c61f964a520e65c1fe3')
138
+ response.hours.timeframes.first.days.should == [1, 2, 3, 4, 5, 6]
139
+ end
140
+
135
141
  context "and getting detailed stats for a venue not managed by user" do
136
142
  should "raise a 'not authorized' API error" do
137
143
  stub_get("https://api.foursquare.com/v2/venues/4ad4c04af964a52065f220e3/stats?oauth_token=#{@client.oauth_token}", nil,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foursquare2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.5
4
+ version: 1.9.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-09 00:00:00.000000000 Z
13
+ date: 2013-04-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -241,8 +241,10 @@ files:
241
241
  - lib/foursquare2/specials.rb
242
242
  - lib/foursquare2/tips.rb
243
243
  - lib/foursquare2/users.rb
244
+ - lib/foursquare2/venuegroups.rb
244
245
  - lib/foursquare2/venues.rb
245
246
  - test/config.rb
247
+ - test/fixtures/campaigns/campaign.json
246
248
  - test/fixtures/campaigns/campaign_created.json
247
249
  - test/fixtures/campaigns/campaigns_list.json
248
250
  - test/fixtures/checkins/checkin.json
@@ -280,6 +282,9 @@ files:
280
282
  - test/fixtures/users/user_tips.json
281
283
  - test/fixtures/users/user_venuestats.json
282
284
  - test/fixtures/users/user_venuestats_friend_id.json
285
+ - test/fixtures/venuegroups/venuegroup.json
286
+ - test/fixtures/venuegroups/venuegroup_add.json
287
+ - test/fixtures/venuegroups/venuegroup_update.json
283
288
  - test/fixtures/venues/explore_venues.json
284
289
  - test/fixtures/venues/managed_venues.json
285
290
  - test/fixtures/venues/no_venues_by_tip.json
@@ -289,6 +294,7 @@ files:
289
294
  - test/fixtures/venues/trending_venues.json
290
295
  - test/fixtures/venues/venue.json
291
296
  - test/fixtures/venues/venue_herenow.json
297
+ - test/fixtures/venues/venue_hours.json
292
298
  - test/fixtures/venues/venue_links.json
293
299
  - test/fixtures/venues/venue_menus.json
294
300
  - test/fixtures/venues/venue_photos.json
@@ -305,6 +311,7 @@ files:
305
311
  - test/test_specials.rb
306
312
  - test/test_tips.rb
307
313
  - test/test_users.rb
314
+ - test/test_venuegroups.rb
308
315
  - test/test_venues.rb
309
316
  homepage: http://github.com/mattmueller/foursquare2
310
317
  licenses:
@@ -321,7 +328,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
321
328
  version: '0'
322
329
  segments:
323
330
  - 0
324
- hash: 1921105295492671255
331
+ hash: -43746040217970609
325
332
  required_rubygems_version: !ruby/object:Gem::Requirement
326
333
  none: false
327
334
  requirements: