checkdin 0.2.4 → 0.2.5

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 (32) hide show
  1. data/lib/checkdin.rb +1 -0
  2. data/lib/checkdin/api_error.rb +5 -4
  3. data/lib/checkdin/client.rb +30 -29
  4. data/lib/checkdin/version.rb +1 -1
  5. data/spec/checkdin/activities_spec.rb +2 -2
  6. data/spec/checkdin/campaigns_spec.rb +2 -2
  7. data/spec/checkdin/client_spec.rb +12 -1
  8. data/spec/checkdin/custom_activities_spec.rb +1 -1
  9. data/spec/checkdin/leaderboard_spec.rb +2 -2
  10. data/spec/checkdin/promotions_spec.rb +2 -2
  11. data/spec/checkdin/users_spec.rb +2 -2
  12. data/spec/checkdin/won_rewards_spec.rb +2 -2
  13. data/spec/fixtures/vcr_cassettes/Checkdin_Activities/viewing_a_list_of_activities.yml +2 -2
  14. data/spec/fixtures/vcr_cassettes/Checkdin_Activities/viewing_a_single_activity.yml +2 -2
  15. data/spec/fixtures/vcr_cassettes/Checkdin_Activities/voting_for_an_activity.yml +25 -25
  16. data/spec/fixtures/vcr_cassettes/Checkdin_Activities/voting_for_an_activity/passing_an_email.yml +26 -26
  17. data/spec/fixtures/vcr_cassettes/Checkdin_Campaigns/viewing_a_list_of_campaigns.yml +2 -2
  18. data/spec/fixtures/vcr_cassettes/Checkdin_Campaigns/viewing_a_single_campaign.yml +3 -3
  19. data/spec/fixtures/vcr_cassettes/Checkdin_CustomActivities.yml +2 -2
  20. data/spec/fixtures/vcr_cassettes/Checkdin_Leaderboard/viewing_a_leaderboard_for_a_campaign.yml +2 -2
  21. data/spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_a_list_of_promotions.yml +3 -3
  22. data/spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_a_single_promotion.yml +3 -3
  23. data/spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_the_votes_leaderboard_for_a_promotion.yml +24 -24
  24. data/spec/fixtures/vcr_cassettes/Checkdin_Promotions/viewing_the_votes_leaderboard_for_a_promotion/limiting_the_number_of_records_returned.yml +24 -24
  25. data/spec/fixtures/vcr_cassettes/Checkdin_Users/viewing_a_list_of_users.yml +2 -2
  26. data/spec/fixtures/vcr_cassettes/Checkdin_Users/viewing_a_single_user.yml +2 -2
  27. data/spec/fixtures/vcr_cassettes/Checkdin_Votes/filtering_by_a_single_user.yml +24 -24
  28. data/spec/fixtures/vcr_cassettes/Checkdin_Votes/viewing_a_list_of_activities.yml +24 -24
  29. data/spec/fixtures/vcr_cassettes/Checkdin_WonRewards/viewing_a_list_of_won_rewards.yml +2 -2
  30. data/spec/fixtures/vcr_cassettes/Checkdin_WonRewards/viewing_a_single_won_reward.yml +2 -2
  31. data/spec/spec_helper.rb +11 -1
  32. metadata +3 -6
@@ -3,6 +3,7 @@ require 'faraday_middleware'
3
3
 
4
4
  require 'openssl'
5
5
  require 'active_support/core_ext/object/to_query'
6
+ require 'active_support/core_ext/object/blank'
6
7
 
7
8
  require 'checkdin/version'
8
9
  require 'checkdin/leaderboard'
@@ -1,14 +1,15 @@
1
1
  module Checkdin
2
2
  class APIError < StandardError
3
3
 
4
- attr_reader :status
4
+ attr_reader :status, :body
5
5
 
6
- def initialize(status)
6
+ def initialize(status, body)
7
7
  @status = status
8
+ @body = body
8
9
  end
9
10
 
10
11
  def message
11
- "Status Code: #{@status}"
12
+ "Status Code: #{status}\nBody: #{body}"
12
13
  end
13
14
  end
14
- end
15
+ end
@@ -14,6 +14,11 @@ module Checkdin
14
14
  include Votes
15
15
 
16
16
  attr_reader :client_id, :client_secret
17
+ attr_reader :ssl
18
+ # Base URL for api requests.
19
+ attr_reader :api_url
20
+
21
+ DEFAULT_API_URL = "https://app.checkd.in/api/v1"
17
22
 
18
23
  #Initialize the client class that will be used for all checkd.in API requests. Requires a valid client_id and client_secret - more info at http://developer.checkd.in
19
24
  #
@@ -21,54 +26,50 @@ module Checkdin
21
26
  # @param [Hash] options
22
27
  # @option options String :client_id Your foursquare app's client_id
23
28
  # @option options String :client_secret Your foursquare app's client_secret
29
+ # @option options String :api_url A custom API url, does not usually have to be overridden
24
30
  # @option options Hash :ssl Additional SSL options (like the path to certificate file)
25
-
31
+
26
32
  def initialize(options={})
27
- @client_id = options[:client_id]
28
- @client_secret = options[:client_secret]
29
- @ssl = options[:ssl].nil? ? Hash.new : options[:ssl]
30
- end
31
-
32
- def ssl
33
- @ssl
33
+ @client_id = options.delete(:client_id)
34
+ @client_secret = options.delete(:client_secret)
35
+ @api_url = options.delete(:api_url) || DEFAULT_API_URL
36
+ @ssl = options.delete(:ssl) || {}
37
+
38
+ raise ArgumentError.new("Unexpected argument given: #{options.inspect}") unless options.blank?
34
39
  end
35
-
36
- # Sets up the connection to be used for all requests based on options passed during initialization.
37
40
 
41
+ # Sets up the connection to be used for all requests based on options passed during initialization.
38
42
  def connection
39
- params = {}
40
- params[:client_id] = @client_id
41
- params[:client_secret] = @client_secret
42
- @connection ||= Faraday::Connection.new(:url => api_url, :ssl => @ssl, :params => params, :headers => default_headers) do |builder|
43
- builder.use Faraday::Request::Multipart
44
- builder.use Faraday::Request::UrlEncoded
43
+ @connection ||= begin
44
+ params = {
45
+ :client_id => client_id,
46
+ :client_secret => client_secret
47
+ }
45
48
 
46
- builder.use FaradayMiddleware::Mashify
47
- builder.use FaradayMiddleware::ParseJson
49
+ Faraday::Connection.new(:url => api_url, :ssl => ssl, :params => params, :headers => default_headers) do |builder|
50
+ builder.use Faraday::Request::Multipart
51
+ builder.use Faraday::Request::UrlEncoded
48
52
 
49
- builder.adapter Faraday.default_adapter
53
+ builder.use FaradayMiddleware::Mashify
54
+ builder.use FaradayMiddleware::ParseJson
50
55
 
56
+ builder.adapter Faraday.default_adapter
57
+ end
51
58
  end
52
59
  end
53
60
 
54
- # Base URL for api requests.
55
-
56
- def api_url
57
- "https://app.checkd.in/api/v1"
58
- end
59
-
60
61
  # Helper method to return errors or desired response data as appropriate.
61
62
  #
62
63
  # Added just for convenience to avoid having to traverse farther down the response just to get to returned data.
63
64
 
64
65
  def return_error_or_body(response)
65
- if response.status == 200
66
+ if response.status == 200
66
67
  response.body
67
68
  else
68
- raise Checkdin::APIError.new(response.status)
69
+ raise Checkdin::APIError.new(response.status, response.body)
69
70
  end
70
71
  end
71
-
72
+
72
73
  private
73
74
 
74
75
 
@@ -80,4 +81,4 @@ module Checkdin
80
81
  end
81
82
 
82
83
  end
83
- end
84
+ end
@@ -1,3 +1,3 @@
1
1
  module Checkdin
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::Activities do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a single activity" do
@@ -69,4 +69,4 @@ describe Checkdin::Activities do
69
69
  end
70
70
  end
71
71
  end
72
- end
72
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::Campaigns do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a single campaign" do
@@ -29,4 +29,4 @@ describe Checkdin::Campaigns do
29
29
  result.first.campaign.name.should == "Check In To Win!"
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -14,5 +14,16 @@ describe Checkdin::Client do
14
14
  it "has the version available" do
15
15
  Checkdin::VERSION.should =~ /^\d\.\d\.\d/
16
16
  end
17
+
18
+ it "takes an optional api_url" do
19
+ instance = Checkdin::Client.new(:api_url => 'https://bogus.checkd.in/api/v7')
20
+ instance.api_url.should == 'https://bogus.checkd.in/api/v7'
21
+ end
22
+
23
+ it "raises an error when an unknown option is passed" do
24
+ expect {
25
+ Checkdin::Client.new(:unexpected_present => 'details here')
26
+ }.to raise_error(ArgumentError, /unexpected_present/)
27
+ end
17
28
  end
18
- end
29
+ end
@@ -4,7 +4,7 @@ describe Checkdin::CustomActivities do
4
4
  use_vcr_cassette
5
5
 
6
6
  before do
7
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
7
+ @client = Checkdin::Client.new(TestCredentials.client_args)
8
8
  end
9
9
 
10
10
  it "should report success when creating a custom activity" do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::Leaderboard do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a leaderboard for a campaign" do
@@ -15,4 +15,4 @@ describe Checkdin::Leaderboard do
15
15
  result.leaders.count.should == 5
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::Promotions do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a single promotion" do
@@ -60,4 +60,4 @@ describe Checkdin::Promotions do
60
60
  end
61
61
  end
62
62
  end
63
- end
63
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::Users do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a single user" do
@@ -55,4 +55,4 @@ describe Checkdin::Users do
55
55
  end
56
56
  end
57
57
  end
58
- end
58
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Checkdin::WonRewards do
4
4
 
5
5
  before do
6
- @client = Checkdin::Client.new(:client_id => '123456', :client_secret => '7890')
6
+ @client = Checkdin::Client.new(TestCredentials.client_args)
7
7
  end
8
8
 
9
9
  context "viewing a single won reward" do
@@ -42,4 +42,4 @@ describe Checkdin::WonRewards do
42
42
  end
43
43
 
44
44
  end
45
- end
45
+ end
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/activities?client_id=123456&client_secret=7890&limit=2
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/activities?client_id={client_id}&client_secret={client_secret}&limit=2
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/activities/236?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/activities/236?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -1,46 +1,46 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :post
5
- uri: https://app.checkd.in:443/api/v1/activities/18881/vote?client_id=123456&client_secret=7890
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/activities/18881/vote?client_id={client_id}&client_secret={client_secret}
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.1
12
- content-length:
12
+ content-length:
13
13
  - "0"
14
- response: !ruby/struct:VCR::Response
15
- status: !ruby/struct:VCR::ResponseStatus
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Mon, 09 Apr 2012 10:38:50 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"78c7474e01ca50b8cfc238ad7974fed1\""
37
- cache-control:
37
+ cache-control:
38
38
  - max-age=0, private, must-revalidate
39
- set-cookie:
39
+ set-cookie:
40
40
  - _checkdin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJWQ3MmVkYzllYzNhZWVhYmU4ZmQ2YjNlN2IxZjEyMjE2BjsAVA%3D%3D--8c08feb9944b93e628e7740a373d79e5adb6bd73; domain=app.checkd.in; path=/; HttpOnly; secure
41
- x-runtime:
41
+ x-runtime:
42
42
  - "0.039170"
43
- x-rack-cache:
43
+ x-rack-cache:
44
44
  - invalidate, pass
45
45
  body: |
46
46
  {"activity":{"type":"twitter_status","id":18881,"created_at":"2012-02-21T16:08:55-06:00","acted_on":{"type":"twitter_status","tweet_fk":172080368760000512,"status":"Check out what I purchased at #mynordstrom http://t.co/DKUXa41E","photo_url":"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg","photo_thumbnail_url":"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg:thumb"},"user":{"id":36,"username":"demomattloadtest","avatar_url":null,"href":"https://app.checkd.in/api/v1/activities.json?user_id=36"},"vote_count":6}}
@@ -1,46 +1,46 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :post
5
- uri: https://app.checkd.in:443/api/v1/activities/18881/vote?client_id=123456&client_secret=7890&user_id=36
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/activities/18881/vote?client_id={client_id}&client_secret={client_secret}&user_id=36
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.1
12
- content-length:
12
+ content-length:
13
13
  - "0"
14
- response: !ruby/struct:VCR::Response
15
- status: !ruby/struct:VCR::ResponseStatus
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Mon, 09 Apr 2012 10:42:37 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"22ee544aa801964a479d745eb9bdba07\""
37
- cache-control:
37
+ cache-control:
38
38
  - max-age=0, private, must-revalidate
39
- set-cookie:
39
+ set-cookie:
40
40
  - _checkdin_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTYyNjY0NTlhMThkZmFjNTJlMzcwMTA4NTc0OThiMWZlBjsAVA%3D%3D--c70adeb132862f669fc85fc8e5e643ea2b811b57; domain=app.checkd.in; path=/; HttpOnly; secure
41
- x-runtime:
42
- - "0.037890"
43
- x-rack-cache:
41
+ x-runtime:
42
+ - "0.03{client_secret}"
43
+ x-rack-cache:
44
44
  - invalidate, pass
45
45
  body: |
46
46
  {"activity":{"type":"twitter_status","id":18881,"created_at":"2012-02-21T16:08:55-06:00","acted_on":{"type":"twitter_status","tweet_fk":172080368760000512,"status":"Check out what I purchased at #mynordstrom http://t.co/DKUXa41E","photo_url":"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg","photo_thumbnail_url":"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg:thumb"},"user":{"id":36,"username":"demomattloadtest","avatar_url":null,"href":"https://app.checkd.in/api/v1/activities.json?user_id=36"},"vote_count":7}}
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/campaigns?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/campaigns?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/campaigns/2?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/campaigns/2?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -45,7 +45,7 @@
45
45
  coffee! Enjoy!","terms":"Offer only good at some locations.","above_21_only":false,"ends_at":"2012-10-16T07:51:32-05:00","href":"https://app.checkd.in/api/v1/promotions/8.json","type":"promotion_lbs_checkin","place_groups":[{"place_group":{"name":"Stores","href":"https://app.checkd.in/api/v1/place_groups/2.json"}}],"reward":{"private_delivery_description":"Thank
46
46
  you for checking-in five times! Because you
47
47
  are such a loyal customer, we would like to treat you to a free medium coffee!
48
- ","public_delivery_description":"Free coffee
48
+ ","public_delivery_description":"Free coffee
49
49
  for every 5 visits - check it out - http://something.com","single_delivery":false,"type":"badge_reward","reward_file":"5thCheckinBarcode.png"},"trigger_schedule":{"rewarding":"once","winner_picked":"activity_interval","interval":5,"human_readable":"Rewarded
50
50
  once when a user reaches 5 relevant actions or points."}}}]}}'
51
51
  http_version: '1.1'
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :post
5
- uri: https://app.checkd.in:443/api/v1/custom_activities?client_id=123456&client_secret=7890&custom_activity_node_id=1&email=muellermr@gmail.com
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/custom_activities?client_id={client_id}&client_secret={client_secret}&custom_activity_node_id=1&email=muellermr@gmail.com
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/campaigns/2/leaderboard?client_id=123456&client_secret=7890&limit=5
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/campaigns/2/leaderboard?client_id={client_id}&client_secret={client_secret}&limit=5
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/promotions?client_id=123456&client_secret=7890&limit=2
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/promotions?client_id={client_id}&client_secret={client_secret}&limit=2
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -42,7 +42,7 @@
42
42
  for every 5 check ins!","description":"Every 5 times you check in at our new
43
43
  location you will be rewarded with a free coffee! Enjoy!","terms":"Offer
44
44
  only good redeem same or next business day.","above_21_only":false,"ends_at":"2012-10-16T07:51:32-05:00","href":"https://app.checkd.in/api/v1/promotions/8.json","type":"promotion_lbs_checkin","place_groups":[{"place_group":{"name":"Stores","href":"https://app.checkd.in/api/v1/place_groups/2.json"}}],"reward":{"private_delivery_description":"Thank
45
- you for checking-in five times","public_delivery_description":"Free coffee
45
+ you for checking-in five times","public_delivery_description":"Free coffee
46
46
  for every 5 visits - check it out - http://something.com","single_delivery":false,"type":"badge_reward","reward_file":"5thCheckinBarcode.png"},"trigger_schedule":{"rewarding":"once","winner_picked":"activity_interval","interval":5,"human_readable":"Rewarded
47
47
  once when a user reaches 5 relevant actions or points."},"campaign":{"name":"Check
48
48
  In To Win","description":"Check in to win free coffee and
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/promotions/8?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/promotions/8?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -43,7 +43,7 @@
43
43
  rewarded with a free coffee! Enjoy!","terms":"Offer only good some places.","above_21_only":false,"ends_at":"2012-10-16T07:51:32-05:00","href":"https://app.checkd.in/api/v1/promotions/8.json","type":"promotion_lbs_checkin","place_groups":[{"place_group":{"name":"Stores","href":"https://app.checkd.in/api/v1/place_groups/2.json"}}],"reward":{"private_delivery_description":"Thank
44
44
  you for checking-in five times! Because you
45
45
  are such a loyal customer, we would like to treat you to a free medium coffee!
46
- ","public_delivery_description":"Free coffee
46
+ ","public_delivery_description":"Free coffee
47
47
  for every 5 visits - check it out - http://something.com","single_delivery":false,"type":"badge_reward","reward_file":"DD-5thCheckinBarcode.png"},"trigger_schedule":{"rewarding":"once","winner_picked":"activity_interval","interval":5,"human_readable":"Rewarded
48
48
  once when a user reaches 5 relevant actions or points."},"campaign":{"name":"Check
49
49
  In To Win","description":"Check in to win free coffee and
@@ -1,44 +1,44 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/promotions/54/votes_leaderboard?client_id=123456&client_secret=7890&limit
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/promotions/54/votes_leaderboard?client_id={client_id}&client_secret={client_secret}&limit
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.1
12
- accept-encoding:
12
+ accept-encoding:
13
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
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Mon, 09 Apr 2012 11:00:42 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"5e76880528d8f34bcf0b8faae48936d6\""
37
- cache-control:
37
+ cache-control:
38
38
  - must-revalidate, private, max-age=0
39
- x-runtime:
39
+ x-runtime:
40
40
  - "0.123999"
41
- x-rack-cache:
41
+ x-rack-cache:
42
42
  - miss
43
43
  body: "{\"promotion\":{\"title\":\"A voting promotion!\",\"description\":\"You iz winning.\",\"terms\":\"\",\"above_21_only\":false,\"ends_at\":\"2012-05-08T05:42:00-05:00\",\"href\":\"https://app.checkd.in/api/v1/promotions/54.json\",\"type\":\"promotion_photo\",\"twitter_hashtag\":\"#mynordstrom\",\"participant_status_message\":null,\"reward\":{\"private_delivery_description\":\"You won\",\"public_delivery_description\":\"\",\"single_delivery\":false,\"type\":\"point_reward\",\"reward_points\":100},\"trigger_schedule\":{\"rewarding\":\"many\",\"winner_picked\":\"activity_interval\",\"interval\":1,\"human_readable\":\"Rewarded every time the same user performs a relevant action.\"},\"votes_leaderboard\":{\"total_pages\":1,\"activities\":[{\"activity\":{\"type\":\"twitter_status\",\"id\":18881,\"created_at\":\"2012-02-21T16:08:55-06:00\",\"acted_on\":{\"type\":\"twitter_status\",\"tweet_fk\":172080368760000512,\"status\":\"Check out what I purchased at #mynordstrom http://t.co/DKUXa41E\",\"photo_url\":\"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg\",\"photo_thumbnail_url\":\"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg:thumb\"},\"user\":{\"id\":36,\"username\":\"demomattloadtest\",\"avatar_url\":null,\"href\":\"https://app.checkd.in/api/v1/activities.json?user_id=36\"},\"href\":\"https://app.checkd.in/api/v1/activities/18881.json\",\"vote_count\":7}},{\"activity\":{\"type\":\"twitter_status\",\"id\":18882,\"created_at\":\"2012-02-22T09:08:47-06:00\",\"acted_on\":{\"type\":\"twitter_status\",\"tweet_fk\":172337035716198401,\"status\":\"Check out #mynordstrom http://t.co/bvqmQX7B\",\"photo_url\":\"https://p.twimg.com/AmRDnvPCAAIYYMY.jpg\",\"photo_thumbnail_url\":\"https://p.twimg.com/AmRDnvPCAAIYYMY.jpg:thumb\"},\"user\":{\"id\":36,\"username\":\"demomattloadtest\",\"avatar_url\":null,\"href\":\"https://app.checkd.in/api/v1/activities.json?user_id=36\"},\"href\":\"https://app.checkd.in/api/v1/activities/18882.json\",\"vote_count\":0}},{\"activity\":{\"type\":\"twitter_status\",\"id\":18883,\"created_at\":\"2012-02-22T09:55:58-06:00\",\"acted_on\":{\"type\":\"twitter_status\",\"tweet_fk\":172348911032336384,\"status\":\"Check out this cool purchase #mynordstrom http://t.co/JKXzWuVu\",\"photo_url\":\"https://p.twimg.com/AmROa-PCAAAcMe1.jpg\",\"photo_thumbnail_url\":\"https://p.twimg.com/AmROa-PCAAAcMe1.jpg:thumb\"},\"user\":{\"id\":36,\"username\":\"demomattloadtest\",\"avatar_url\":null,\"href\":\"https://app.checkd.in/api/v1/activities.json?user_id=36\"},\"href\":\"https://app.checkd.in/api/v1/activities/18883.json\",\"vote_count\":0}}]},\"campaign\":{\"name\":\"Nordstrom Rewards\",\"description\":\"Earn discounts and other great rewards for joining Nordstrom Fashion Rewards!\",\"start_date\":\"2011-12-14\",\"end_date\":\"2012-06-01\",\"href\":\"https://app.checkd.in/api/v1/campaigns/11.json\"}}}"
44
44
  http_version: "1.1"
@@ -1,44 +1,44 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/promotions/54/votes_leaderboard?client_id=123456&client_secret=7890&limit=1
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/promotions/54/votes_leaderboard?client_id={client_id}&client_secret={client_secret}&limit=1
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.1
12
- accept-encoding:
12
+ accept-encoding:
13
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
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Mon, 09 Apr 2012 11:02:11 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"616689e5a2d0af0ef532965e0f6aad51\""
37
- cache-control:
37
+ cache-control:
38
38
  - must-revalidate, private, max-age=0
39
- x-runtime:
39
+ x-runtime:
40
40
  - "0.128383"
41
- x-rack-cache:
41
+ x-rack-cache:
42
42
  - miss
43
43
  body: "{\"promotion\":{\"title\":\"A voting promotion!\",\"description\":\"You iz winning\",\"terms\":\"\",\"above_21_only\":false,\"ends_at\":\"2012-05-08T05:42:00-05:00\",\"href\":\"https://app.checkd.in/api/v1/promotions/54.json\",\"type\":\"promotion_photo\",\"twitter_hashtag\":\"#mynordstrom\",\"participant_status_message\":null,\"reward\":{\"private_delivery_description\":\"\",\"public_delivery_description\":\"\",\"single_delivery\":false,\"type\":\"point_reward\",\"reward_points\":100},\"trigger_schedule\":{\"rewarding\":\"many\",\"winner_picked\":\"activity_interval\",\"interval\":1,\"human_readable\":\"Rewarded every time the same user performs a relevant action.\"},\"votes_leaderboard\":{\"total_pages\":3,\"activities\":[{\"activity\":{\"type\":\"twitter_status\",\"id\":18881,\"created_at\":\"2012-02-21T16:08:55-06:00\",\"acted_on\":{\"type\":\"twitter_status\",\"tweet_fk\":172080368760000512,\"status\":\"Check out what I purchased at #mynordstrom http://t.co/DKUXa41E\",\"photo_url\":\"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg\",\"photo_thumbnail_url\":\"https://p.twimg.com/AmNaLwUCEAIt1v3.jpg:thumb\"},\"user\":{\"id\":36,\"username\":\"demomattloadtest\",\"avatar_url\":null,\"href\":\"https://app.checkd.in/api/v1/activities.json?user_id=36\"},\"href\":\"https://app.checkd.in/api/v1/activities/18881.json\",\"vote_count\":7}}]},\"campaign\":{\"name\":\"Nordstrom Rewards\",\"description\":\"Earn discounts and other great rewards for joining Nordstrom Fashion Rewards!\",\"start_date\":\"2011-12-14\",\"end_date\":\"2012-06-01\",\"href\":\"https://app.checkd.in/api/v1/campaigns/11.json\"}}}"
44
44
  http_version: "1.1"
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/users?client_id=123456&client_secret=7890&limit=2
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/users?client_id={client_id}&client_secret={client_secret}&limit=2
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/users/187?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/users/187?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -1,44 +1,44 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/votes?client_id=123456&client_secret=7890&user_id=36
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/votes?client_id={client_id}&client_secret={client_secret}&user_id=36
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.2
12
- accept-encoding:
12
+ accept-encoding:
13
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
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Tue, 17 Apr 2012 15:57:37 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"e5be3080253b60063d29411e65400701\""
37
- cache-control:
37
+ cache-control:
38
38
  - must-revalidate, private, max-age=0
39
- x-runtime:
39
+ x-runtime:
40
40
  - "0.101455"
41
- x-rack-cache:
41
+ x-rack-cache:
42
42
  - miss
43
43
  body: "{\"total_pages\":1,\"votes\":[{\"vote\":{\"created_at\":\"2012-04-09T05:42:37-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:52:18-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:52:12-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}}]}"
44
44
  http_version: "1.1"
@@ -1,44 +1,44 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/votes?client_id=123456&client_secret=7890
6
- body:
7
- headers:
8
- accept:
5
+ uri: https://app.checkd.in:443/api/v1/votes?client_id={client_id}&client_secret={client_secret}
6
+ body:
7
+ headers:
8
+ accept:
9
9
  - application/json
10
- user-agent:
10
+ user-agent:
11
11
  - checkdin ruby gem 0.2.2
12
- accept-encoding:
12
+ accept-encoding:
13
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
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
17
17
  message: OK
18
- headers:
19
- server:
18
+ headers:
19
+ server:
20
20
  - nginx/1.0.11
21
- date:
21
+ date:
22
22
  - Tue, 17 Apr 2012 15:57:36 GMT
23
- content-type:
23
+ content-type:
24
24
  - application/json; charset=utf-8
25
- transfer-encoding:
25
+ transfer-encoding:
26
26
  - chunked
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- status:
29
+ status:
30
30
  - 200 OK
31
- strict-transport-security:
31
+ strict-transport-security:
32
32
  - max-age=31536000
33
- x-ua-compatible:
33
+ x-ua-compatible:
34
34
  - IE=Edge,chrome=1
35
- etag:
35
+ etag:
36
36
  - "\"0b1ec43ded6cc7875c4c284e7e112874\""
37
- cache-control:
37
+ cache-control:
38
38
  - must-revalidate, private, max-age=0
39
- x-runtime:
39
+ x-runtime:
40
40
  - "0.047213"
41
- x-rack-cache:
41
+ x-rack-cache:
42
42
  - miss
43
43
  body: "{\"total_pages\":1,\"votes\":[{\"vote\":{\"created_at\":\"2012-04-09T05:42:37-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-09T05:38:50-05:00\",\"user\":null,\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:52:18-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:52:12-05:00\",\"user\":{\"id\":36,\"href\":\"https://staging.checkd.in/api/v1/users/36.json\"},\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:51:53-05:00\",\"user\":null,\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:30:05-05:00\",\"user\":null,\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}},{\"vote\":{\"created_at\":\"2012-04-08T06:26:47-05:00\",\"user\":null,\"activity\":{\"id\":18881,\"href\":\"https://staging.checkd.in/api/v1/activities/18881.json\"}}}]}"
44
44
  http_version: "1.1"
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/won_rewards?client_id=123456&client_secret=7890&limit=2
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/won_rewards?client_id={client_id}&client_secret={client_secret}&limit=2
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -2,8 +2,8 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: https://app.checkd.in:443/api/v1/won_rewards/142?client_id=123456&client_secret=7890
6
- body: !!null
5
+ uri: https://app.checkd.in:443/api/v1/won_rewards/142?client_id={client_id}&client_secret={client_secret}
6
+ body: !!null
7
7
  headers:
8
8
  accept:
9
9
  - application/json
@@ -9,6 +9,8 @@ require 'rspec'
9
9
  require 'webmock/rspec'
10
10
  require 'vcr'
11
11
 
12
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
13
+
12
14
  # Disallow all HTTP connections
13
15
  WebMock.disable_net_connect!
14
16
 
@@ -17,6 +19,14 @@ VCR.config do |config|
17
19
  config.cassette_library_dir = File.join('spec', 'fixtures', 'vcr_cassettes')
18
20
 
19
21
  config.stub_with :webmock
22
+
23
+ config.filter_sensitive_data('{client_id}') { TestCredentials.client_id }
24
+ config.filter_sensitive_data('{client_secret}') { TestCredentials.client_secret }
25
+ config.filter_sensitive_data('{api_url}') { TestCredentials.api_url }
26
+
27
+ config.default_cassette_options = {
28
+ :match_requests_on => [ :path ] # ignore hostname when finding a matching request in the VCR recording
29
+ }
20
30
  end
21
31
 
22
32
  RSpec.configure do |config|
@@ -36,4 +46,4 @@ RSpec.configure do |config|
36
46
  end
37
47
  end
38
48
 
39
- DEFAULT_HOST = 'http://www.example.com'
49
+ DEFAULT_HOST = 'http://www.example.com'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: checkdin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matt Mueller
@@ -19,10 +19,7 @@ dependencies:
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0.6"
25
- - - <
22
+ - - ~>
26
23
  - !ruby/object:Gem::Version
27
24
  version: "0.8"
28
25
  type: :runtime
@@ -35,7 +32,7 @@ dependencies:
35
32
  requirements:
36
33
  - - ">="
37
34
  - !ruby/object:Gem::Version
38
- version: "0.8"
35
+ version: "0"
39
36
  type: :runtime
40
37
  version_requirements: *id002
41
38
  - !ruby/object:Gem::Dependency