checkdin 0.2.8 → 0.2.9
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/Gemfile.lock +1 -1
- data/lib/checkdin/client.rb +1 -0
- data/lib/checkdin/push_api_subscriptions.rb +39 -0
- data/lib/checkdin/user_bridge.rb +2 -1
- data/lib/checkdin/users.rb +3 -2
- data/lib/checkdin/version.rb +1 -1
- data/lib/checkdin.rb +1 -0
- data/spec/checkdin/push_api_subscriptions_spec.rb +50 -0
- data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/disabling_a_push_api_subscription.yml +32 -0
- data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/enabling_a_push_api_subscription.yml +32 -0
- data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/viewing_a_list_of_push_api_subscriptions.yml +32 -0
- data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/viewing_a_single_push_api_subscription.yml +32 -0
- metadata +7 -1
data/Gemfile.lock
CHANGED
data/lib/checkdin/client.rb
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Checkdin
|
|
2
|
+
module PushApiSubscriptions
|
|
3
|
+
|
|
4
|
+
# Retrieve information about a push API subscription
|
|
5
|
+
#
|
|
6
|
+
# param [Integer] id The ID of the subscription
|
|
7
|
+
|
|
8
|
+
def push_api_subscription(id)
|
|
9
|
+
response = connection.get("push_api_subscriptions/#{id}")
|
|
10
|
+
return_error_or_body(response)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Get a list of all push api subscriptions for the authenticating client.
|
|
14
|
+
|
|
15
|
+
def push_api_subscriptions
|
|
16
|
+
response = connection.get("push_api_subscriptions")
|
|
17
|
+
return_error_or_body(response)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Enable a push API subscription
|
|
21
|
+
#
|
|
22
|
+
# param [Integer] id The ID of the subscription to enable
|
|
23
|
+
|
|
24
|
+
def enable_push_api_subscription(id)
|
|
25
|
+
response = connection.put("push_api_subscriptions/#{id}/enable")
|
|
26
|
+
return_error_or_body(response)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Disable a push API subscription
|
|
30
|
+
#
|
|
31
|
+
# param [Integer] id The ID of the subscription to disable
|
|
32
|
+
|
|
33
|
+
def disable_push_api_subscription(id)
|
|
34
|
+
response = connection.put("push_api_subscriptions/#{id}/disable")
|
|
35
|
+
return_error_or_body(response)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/checkdin/user_bridge.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Checkdin
|
|
|
5
5
|
attr :client_identifier, :bridge_secret
|
|
6
6
|
attr :checkdin_landing_url
|
|
7
7
|
|
|
8
|
-
# Used to build the authenticated parameters for logging in an end-user on
|
|
8
|
+
# Used to build the authenticated parameters for logging in an end-user on
|
|
9
9
|
# checkd.in via a redirect.
|
|
10
10
|
#
|
|
11
11
|
# options - a hash with a the following values defined:
|
|
@@ -52,6 +52,7 @@ module Checkdin
|
|
|
52
52
|
# classification - OPTIONAL, the internal group or classification a user belongs to
|
|
53
53
|
# delivery_email - OPTIONAL, whether a user should receive email notifications
|
|
54
54
|
# delivery_sms - OPTIONAL, whether a user should receive sms notifications
|
|
55
|
+
# campaign_id - OPTIONAL, automatically join a user to this campaign, rewarding existing known actions
|
|
55
56
|
#
|
|
56
57
|
# Returns a URL you can use for redirecting a user. Notice this will expire, so it should
|
|
57
58
|
# be generated and used only when a user actually wants to log into checkd.in.
|
data/lib/checkdin/users.rb
CHANGED
|
@@ -45,8 +45,9 @@ module Checkdin
|
|
|
45
45
|
# @option options String :mobile_number - OPTIONAL, XXXYYYZZZZ format
|
|
46
46
|
# @option options String :postal_code_text - OPTIONAL, XXXXX format
|
|
47
47
|
# @option options String :classification - OPTIONAL, the internal group or classification a user belongs to
|
|
48
|
-
# @option options
|
|
49
|
-
# @option options
|
|
48
|
+
# @option options Boolean :delivery_email - OPTIONAL, whether a user should receive email notifications
|
|
49
|
+
# @option options Boolean :delivery_sms - OPTIONAL, whether a user should receive sms notifications
|
|
50
|
+
# @option options Integer :campaign_id - OPTIONAL, automatically join a user to this campaign, rewarding existing known actions
|
|
50
51
|
|
|
51
52
|
def create_user(options={})
|
|
52
53
|
response = connection.post do |req|
|
data/lib/checkdin/version.rb
CHANGED
data/lib/checkdin.rb
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Checkdin::PushApiSubscriptions do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@client = Checkdin::Client.new(TestCredentials.client_args)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
context "viewing a single push api subscription" do
|
|
10
|
+
use_vcr_cassette
|
|
11
|
+
let(:result) { @client.push_api_subscription(1) }
|
|
12
|
+
|
|
13
|
+
it "should make the push API subscription's url available" do
|
|
14
|
+
result.push_api_subscription.push_url.should == "http://test.com"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should make the push API subscription's push secret available" do
|
|
18
|
+
result.push_api_subscription.secret.should == "6dec79a3034468c530fc"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "viewing a list of push api subscriptions" do
|
|
23
|
+
use_vcr_cassette
|
|
24
|
+
let(:result) { @client.push_api_subscriptions }
|
|
25
|
+
|
|
26
|
+
it "should make a list of push API subscriptions available" do
|
|
27
|
+
result.count.should == 2
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "enabling a push api subscription" do
|
|
32
|
+
use_vcr_cassette
|
|
33
|
+
let(:result) { @client.enable_push_api_subscription(2) }
|
|
34
|
+
|
|
35
|
+
it "should enable the subscription and return it" do
|
|
36
|
+
result.push_api_subscription.state.should == "enabled"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "disabling a push api subscription" do
|
|
41
|
+
use_vcr_cassette
|
|
42
|
+
let(:result) { @client.disable_push_api_subscription(1) }
|
|
43
|
+
|
|
44
|
+
it "should disable the subscription and return it" do
|
|
45
|
+
result.push_api_subscription.state.should == "disabled"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
end
|
data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/disabling_a_push_api_subscription.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :put
|
|
5
|
+
uri: http://checkd-in-core.dev:80/api/v1/push_api_subscriptions/1/disable?client_id={client_id}&client_secret={client_secret}
|
|
6
|
+
body:
|
|
7
|
+
headers:
|
|
8
|
+
accept:
|
|
9
|
+
- application/json
|
|
10
|
+
user-agent:
|
|
11
|
+
- checkdin ruby gem 0.2.8
|
|
12
|
+
content-length:
|
|
13
|
+
- "0"
|
|
14
|
+
response: !ruby/struct:VCR::Response
|
|
15
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
16
|
+
code: 200
|
|
17
|
+
message: OK
|
|
18
|
+
headers:
|
|
19
|
+
content-type:
|
|
20
|
+
- application/json; charset=utf-8
|
|
21
|
+
x-ua-compatible:
|
|
22
|
+
- IE=Edge
|
|
23
|
+
etag:
|
|
24
|
+
- "\"5dc194884d762f9b11af7d509861636d\""
|
|
25
|
+
cache-control:
|
|
26
|
+
- max-age=0, private, must-revalidate
|
|
27
|
+
x-request-id:
|
|
28
|
+
- 65ef6ad8a9be72f97cbb4f1480e3f575
|
|
29
|
+
x-runtime:
|
|
30
|
+
- "0.114155"
|
|
31
|
+
body: "{\"push_api_subscription\":{\"push_url\":\"http://test.com\",\"state\":\"disabled\",\"reward_won_monitored\":false,\"activity_created_monitored\":true,\"user_created_monitored\":false,\"secret\":\"6dec79a3034468c530fc\",\"campaign\":null}}"
|
|
32
|
+
http_version: "1.1"
|
data/spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/enabling_a_push_api_subscription.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :put
|
|
5
|
+
uri: http://checkd-in-core.dev:80/api/v1/push_api_subscriptions/2/enable?client_id={client_id}&client_secret={client_secret}
|
|
6
|
+
body:
|
|
7
|
+
headers:
|
|
8
|
+
accept:
|
|
9
|
+
- application/json
|
|
10
|
+
user-agent:
|
|
11
|
+
- checkdin ruby gem 0.2.8
|
|
12
|
+
content-length:
|
|
13
|
+
- "0"
|
|
14
|
+
response: !ruby/struct:VCR::Response
|
|
15
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
16
|
+
code: 200
|
|
17
|
+
message: OK
|
|
18
|
+
headers:
|
|
19
|
+
content-type:
|
|
20
|
+
- application/json; charset=utf-8
|
|
21
|
+
x-ua-compatible:
|
|
22
|
+
- IE=Edge
|
|
23
|
+
etag:
|
|
24
|
+
- "\"9f2a4641681422d0e3958302e9dc7f15\""
|
|
25
|
+
cache-control:
|
|
26
|
+
- max-age=0, private, must-revalidate
|
|
27
|
+
x-request-id:
|
|
28
|
+
- 05ba934d598cec7b44ef90346ea4f515
|
|
29
|
+
x-runtime:
|
|
30
|
+
- "0.061926"
|
|
31
|
+
body: "{\"push_api_subscription\":{\"push_url\":\"http://campaign-specific.com\",\"state\":\"enabled\",\"reward_won_monitored\":false,\"activity_created_monitored\":false,\"user_created_monitored\":true,\"secret\":\"06c5b4a97848faec4a94\",\"campaign\":{\"href\":\"{api_url}/campaigns/7.json\",\"id\":7}}}"
|
|
32
|
+
http_version: "1.1"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :get
|
|
5
|
+
uri: http://checkd-in-core.dev:80/api/v1/push_api_subscriptions?client_id={client_id}&client_secret={client_secret}
|
|
6
|
+
body:
|
|
7
|
+
headers:
|
|
8
|
+
accept:
|
|
9
|
+
- application/json
|
|
10
|
+
user-agent:
|
|
11
|
+
- checkdin ruby gem 0.2.8
|
|
12
|
+
accept-encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
response: !ruby/struct:VCR::Response
|
|
15
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
16
|
+
code: 200
|
|
17
|
+
message: OK
|
|
18
|
+
headers:
|
|
19
|
+
content-type:
|
|
20
|
+
- application/json; charset=utf-8
|
|
21
|
+
x-ua-compatible:
|
|
22
|
+
- IE=Edge
|
|
23
|
+
etag:
|
|
24
|
+
- "\"e05a34bf305d4016a48df13b2b82f668\""
|
|
25
|
+
cache-control:
|
|
26
|
+
- max-age=0, private, must-revalidate
|
|
27
|
+
x-request-id:
|
|
28
|
+
- 81063280e22214167c45926165975d79
|
|
29
|
+
x-runtime:
|
|
30
|
+
- "0.161668"
|
|
31
|
+
body: "[{\"push_api_subscription\":{\"push_url\":\"http://test.com\",\"state\":\"enabled\",\"reward_won_monitored\":false,\"activity_created_monitored\":true,\"user_created_monitored\":false,\"secret\":\"6dec79a3034468c530fc\",\"campaign\":null}},{\"push_api_subscription\":{\"push_url\":\"http://campaign-specific.com\",\"state\":\"disabled\",\"reward_won_monitored\":false,\"activity_created_monitored\":false,\"user_created_monitored\":true,\"secret\":\"06c5b4a97848faec4a94\",\"campaign\":{\"href\":\"{api_url}/campaigns/7.json\",\"id\":7}}}]"
|
|
32
|
+
http_version: "1.1"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
|
3
|
+
request: !ruby/struct:VCR::Request
|
|
4
|
+
method: :get
|
|
5
|
+
uri: http://checkd-in-core.dev:80/api/v1/push_api_subscriptions/1?client_id={client_id}&client_secret={client_secret}
|
|
6
|
+
body:
|
|
7
|
+
headers:
|
|
8
|
+
accept:
|
|
9
|
+
- application/json
|
|
10
|
+
user-agent:
|
|
11
|
+
- checkdin ruby gem 0.2.8
|
|
12
|
+
accept-encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
response: !ruby/struct:VCR::Response
|
|
15
|
+
status: !ruby/struct:VCR::ResponseStatus
|
|
16
|
+
code: 200
|
|
17
|
+
message: OK
|
|
18
|
+
headers:
|
|
19
|
+
content-type:
|
|
20
|
+
- application/json; charset=utf-8
|
|
21
|
+
x-ua-compatible:
|
|
22
|
+
- IE=Edge
|
|
23
|
+
etag:
|
|
24
|
+
- "\"9d54b3e26adb43319412054e434f95b4\""
|
|
25
|
+
cache-control:
|
|
26
|
+
- max-age=0, private, must-revalidate
|
|
27
|
+
x-request-id:
|
|
28
|
+
- 229fde8356e2089293d1970696570ade
|
|
29
|
+
x-runtime:
|
|
30
|
+
- "0.135453"
|
|
31
|
+
body: "{\"push_api_subscription\":{\"push_url\":\"http://test.com\",\"state\":\"enabled\",\"reward_won_monitored\":false,\"activity_created_monitored\":true,\"user_created_monitored\":false,\"secret\":\"6dec79a3034468c530fc\",\"campaign\":null}}"
|
|
32
|
+
http_version: "1.1"
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: checkdin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.2.
|
|
5
|
+
version: 0.2.9
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Matt Mueller
|
|
@@ -159,6 +159,7 @@ files:
|
|
|
159
159
|
- lib/checkdin/custom_activities.rb
|
|
160
160
|
- lib/checkdin/leaderboard.rb
|
|
161
161
|
- lib/checkdin/promotions.rb
|
|
162
|
+
- lib/checkdin/push_api_subscriptions.rb
|
|
162
163
|
- lib/checkdin/users.rb
|
|
163
164
|
- lib/checkdin/user_bridge.rb
|
|
164
165
|
- lib/checkdin/version.rb
|
|
@@ -171,6 +172,7 @@ files:
|
|
|
171
172
|
- spec/checkdin/custom_activities_spec.rb
|
|
172
173
|
- spec/checkdin/leaderboard_spec.rb
|
|
173
174
|
- spec/checkdin/promotions_spec.rb
|
|
175
|
+
- spec/checkdin/push_api_subscriptions_spec.rb
|
|
174
176
|
- spec/checkdin/users_spec.rb
|
|
175
177
|
- spec/checkdin/user_bridge_spec.rb
|
|
176
178
|
- spec/checkdin/won_rewards_spec.rb
|
|
@@ -188,6 +190,10 @@ files:
|
|
|
188
190
|
- spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_a_single_promotion.yml
|
|
189
191
|
- spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_the_votes_leaderboard_for_a_promotion.yml
|
|
190
192
|
- spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_the_votes_leaderboard_for_a_promotion/limiting_the_number_of_records_returned.yml
|
|
193
|
+
- spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/disabling_a_push_api_subscription.yml
|
|
194
|
+
- spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/enabling_a_push_api_subscription.yml
|
|
195
|
+
- spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/viewing_a_list_of_push_api_subscriptions.yml
|
|
196
|
+
- spec/fixtures/vcr_cassettes/Checkdin_PushApiSubscriptions/viewing_a_single_push_api_subscription.yml
|
|
191
197
|
- spec/fixtures/vcr_cassettes/Checkdin_Users/viewing_a_list_of_users.yml
|
|
192
198
|
- spec/fixtures/vcr_cassettes/Checkdin_Users/viewing_a_single_user.yml
|
|
193
199
|
- spec/fixtures/vcr_cassettes/Checkdin_Votes/filtering_by_a_single_user.yml
|