foursquare2 1.9.3 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/foursquare2.gemspec +3 -2
- data/lib/foursquare2/campaigns.rb +31 -0
- data/test/fixtures/campaigns/campaigns_list.json +37 -0
- data/test/test_campaigns.rb +15 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.4
|
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.
|
8
|
+
s.version = "1.9.4"
|
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-
|
12
|
+
s.date = "2013-03-03"
|
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 = [
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/foursquare2/venues.rb",
|
41
41
|
"test/config.rb",
|
42
42
|
"test/fixtures/campaigns/campaign_created.json",
|
43
|
+
"test/fixtures/campaigns/campaigns_list.json",
|
43
44
|
"test/fixtures/checkins/checkin.json",
|
44
45
|
"test/fixtures/checkins/checkin_reply.json",
|
45
46
|
"test/fixtures/checkins/friend_checkins.json",
|
@@ -19,6 +19,37 @@ module Foursquare2
|
|
19
19
|
end
|
20
20
|
return_error_or_body(response, response.body.response.campaign)
|
21
21
|
end
|
22
|
+
|
23
|
+
# Get a list of campaigns
|
24
|
+
# Details on param options can be found at https://developer.foursquare.com/docs/campaigns/list
|
25
|
+
#
|
26
|
+
# @param [Hash] options
|
27
|
+
# @option options String :specialId - if specified, limits response to campaigns involving the given special
|
28
|
+
# @option options String :groupId - if specified, limits response to campaigns involving the given group
|
29
|
+
# @option options String :status - which campaigns to return: pending,scheduled,active,expired,depleted,stopped,notStarted,ended,all (default=all)
|
30
|
+
#
|
31
|
+
#
|
32
|
+
|
33
|
+
def list_campaigns(options={})
|
34
|
+
response = connection.get do |req|
|
35
|
+
req.url "campaigns/list", options
|
36
|
+
end
|
37
|
+
return_error_or_body(response, response.body.response.campaigns.items)
|
38
|
+
end
|
39
|
+
|
40
|
+
# End a campaign
|
41
|
+
# Details on param can be found at https://developer.foursquare.com/docs/campaigns/end
|
42
|
+
#
|
43
|
+
# @campaign_id String :campaignId - The ID of the campaign to end. Must be specified. Pass in as a string and not as a hash.
|
44
|
+
#
|
45
|
+
#
|
46
|
+
|
47
|
+
def end_campaign(campaign_id)
|
48
|
+
response = connection.post do |req|
|
49
|
+
req.url "campaigns/#{campaign_id}/end"
|
50
|
+
end
|
51
|
+
return_error_or_body(response, response.body.code)
|
52
|
+
end
|
22
53
|
|
23
54
|
end
|
24
55
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"meta": {
|
3
|
+
"code": 200
|
4
|
+
},
|
5
|
+
"notifications": [
|
6
|
+
{
|
7
|
+
"type": "notificationTray",
|
8
|
+
"item": {
|
9
|
+
"unreadCount": 0
|
10
|
+
}
|
11
|
+
}
|
12
|
+
],
|
13
|
+
"response": {
|
14
|
+
"campaigns": {
|
15
|
+
"count": 1,
|
16
|
+
"items": [
|
17
|
+
{
|
18
|
+
"id": "4e0deba2922e6f94b1410b79",
|
19
|
+
"venues": {
|
20
|
+
"count": 1,
|
21
|
+
"items": [
|
22
|
+
{
|
23
|
+
"id": "4e0deab3922e6f94b1410af3"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
},
|
27
|
+
"startsAt": 1309535356,
|
28
|
+
"specialId": "4e0debea922e6f94b1410bb7",
|
29
|
+
"venueGroupIds": {
|
30
|
+
"count": 0,
|
31
|
+
"items": [ ]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
data/test/test_campaigns.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
+
require 'helper'
|
4
|
+
|
3
5
|
class TestCampaigns < Test::Unit::TestCase
|
4
6
|
|
5
7
|
context "When using the foursquare API and working with campaigns" do
|
@@ -12,6 +14,18 @@ class TestCampaigns < Test::Unit::TestCase
|
|
12
14
|
campaign = @client.add_campaign(:specialId => '4bd876f886ba62b58a6e88b3')
|
13
15
|
campaign.special.id == "4bd876f886ba62b58a6e88b3"
|
14
16
|
end
|
15
|
-
|
17
|
+
|
18
|
+
should "list all campaigns" do
|
19
|
+
stub_get("https://api.foursquare.com/v2/campaigns/list?oauth_token=#{@client.oauth_token}&status=active", "campaigns/campaigns_list.json")
|
20
|
+
campaigns = @client.list_campaigns(:status => 'active')
|
21
|
+
campaigns.first.id.should == "4e0deba2922e6f94b1410b79"
|
22
|
+
end
|
23
|
+
|
24
|
+
should "list campaigns of specialId" do
|
25
|
+
stub_get("https://api.foursquare.com/v2/campaigns/list?oauth_token=#{@client.oauth_token}&specialId=4e0debea922e6f94b1410bb7", "campaigns/campaigns_list.json")
|
26
|
+
campaigns = @client.list_campaigns(:specialId => '4e0debea922e6f94b1410bb7')
|
27
|
+
campaigns.first['specialId'].should == "4e0debea922e6f94b1410bb7"
|
28
|
+
end
|
29
|
+
|
16
30
|
end
|
17
31
|
end
|
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.
|
4
|
+
version: 1.9.4
|
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-
|
13
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- lib/foursquare2/venues.rb
|
245
245
|
- test/config.rb
|
246
246
|
- test/fixtures/campaigns/campaign_created.json
|
247
|
+
- test/fixtures/campaigns/campaigns_list.json
|
247
248
|
- test/fixtures/checkins/checkin.json
|
248
249
|
- test/fixtures/checkins/checkin_reply.json
|
249
250
|
- test/fixtures/checkins/friend_checkins.json
|
@@ -319,7 +320,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
319
320
|
version: '0'
|
320
321
|
segments:
|
321
322
|
- 0
|
322
|
-
hash:
|
323
|
+
hash: 4157346706874056407
|
323
324
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
324
325
|
none: false
|
325
326
|
requirements:
|