access 1.1.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +2 -0
  4. data/.travis.yml +12 -0
  5. data/Guardfile +7 -0
  6. data/README.md +159 -23
  7. data/Rakefile +13 -0
  8. data/access.gemspec +6 -1
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/access.rb +21 -10
  12. data/lib/access/api.rb +188 -64
  13. data/lib/access/autocomplete.rb +11 -0
  14. data/lib/access/campaign.rb +24 -0
  15. data/lib/access/category.rb +16 -2
  16. data/lib/access/channel.rb +24 -0
  17. data/lib/access/city_savings.rb +16 -0
  18. data/lib/access/config.rb +8 -7
  19. data/lib/access/error.rb +8 -2
  20. data/lib/access/filter.rb +30 -2
  21. data/lib/access/info.rb +13 -0
  22. data/lib/access/link.rb +17 -0
  23. data/lib/access/location.rb +17 -2
  24. data/lib/access/member.rb +11 -0
  25. data/lib/access/oauth_application.rb +31 -0
  26. data/lib/access/offer.rb +24 -20
  27. data/lib/access/redeem.rb +11 -4
  28. data/lib/access/report.rb +10 -0
  29. data/lib/access/request.rb +25 -20
  30. data/lib/access/response.rb +127 -0
  31. data/lib/access/spot.rb +28 -0
  32. data/lib/access/store.rb +16 -2
  33. data/lib/access/token.rb +18 -0
  34. data/lib/access/verify.rb +11 -2
  35. data/lib/access/version.rb +1 -1
  36. data/test/access/autocomplete_test.rb +53 -0
  37. data/test/access/category_test.rb +64 -0
  38. data/test/access/city_savings_test.rb +5 -0
  39. data/test/access/filter_test.rb +40 -0
  40. data/test/access/location_test.rb +59 -0
  41. data/test/access/member_test.rb +5 -0
  42. data/test/access/oauth_application_test.rb +91 -0
  43. data/test/access/offer_test.rb +71 -0
  44. data/test/access/redeem_test.rb +38 -0
  45. data/test/access/report_test.rb +36 -0
  46. data/test/access/store_test.rb +65 -0
  47. data/test/access/token_test.rb +35 -0
  48. data/test/access/verify_test.rb +29 -0
  49. data/test/access/version_test.rb +9 -0
  50. data/test/fixtures/autocomplete_search.yml +207 -0
  51. data/test/fixtures/autocomplete_search_categories.yml +181 -0
  52. data/test/fixtures/autocomplete_search_locations.yml +173 -0
  53. data/test/fixtures/autocomplete_search_offers.yml +181 -0
  54. data/test/fixtures/autocomplete_search_stores.yml +185 -0
  55. data/test/fixtures/category_find.yml +303 -0
  56. data/test/fixtures/category_search.yml +683 -0
  57. data/test/fixtures/category_search_fail_member_key.yml +102 -0
  58. data/test/fixtures/filter_find.yml +70 -0
  59. data/test/fixtures/filter_search.yml +195 -0
  60. data/test/fixtures/location_find.yml +923 -0
  61. data/test/fixtures/location_search.yml +378 -0
  62. data/test/fixtures/location_search_fail_member_key.yml +367 -0
  63. data/test/fixtures/national_stores.yml +4135 -0
  64. data/test/fixtures/oauth_application_find.yml +163 -0
  65. data/test/fixtures/oauth_application_search.yml +134 -0
  66. data/test/fixtures/oauth_application_search_fail_member_key.yml +268 -0
  67. data/test/fixtures/oauth_application_token_find.yml +249 -0
  68. data/test/fixtures/oauth_application_token_search.yml +98 -0
  69. data/test/fixtures/offer_find.yml +683 -0
  70. data/test/fixtures/offer_search.yml +329 -0
  71. data/test/fixtures/offer_search_fail_member_key.yml +102 -0
  72. data/test/fixtures/redeem_offer_no_redeem_type.yml +423 -0
  73. data/test/fixtures/store_find.yml +333 -0
  74. data/test/fixtures/store_search.yml +227 -0
  75. data/test/fixtures/store_search_fail_member_key.yml +102 -0
  76. data/test/fixtures/subcategory_find.yml +283 -0
  77. data/test/fixtures/token_find.yml +245 -0
  78. data/test/fixtures/token_search.yml +301 -0
  79. data/test/fixtures/verify_filter.yml +290 -0
  80. data/test/fixtures/verify_token.yml +78 -0
  81. data/test/test_helper.rb +15 -0
  82. metadata +183 -11
  83. data/test/offers/offer_test.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e99cab47666893bfa7332b3460407bf898f3f302
4
- data.tar.gz: ba6667849980ea43b32c22a703ce5cac31ddd451
3
+ metadata.gz: e083e07912e9391f135079ff737459f2d0dcbc3c
4
+ data.tar.gz: fc453c9ca589f35ac8fdbd36303771892960fe3c
5
5
  SHA512:
6
- metadata.gz: 54771695dc0e7b16b949379fba7e8f522b5d960b207a72a43c9c98dd21b3f517a33e6254ffdb73d45057c2a7415227f9f09fce9a51237ec097e00d50673bfc61
7
- data.tar.gz: 82617f27889ee27520468226ba37bb6d468cae801683f6a543b592c2086547ad23b05821eb9b369e6e910eb044417bbacea31ace018283da1eef7d672bdabe0e
6
+ metadata.gz: 58137b7e514a16d52e944e16a989dad303d2ec44ddf910211be166a73bd2e5d4bf3daeab509c6ced7b8fa8b41409d63f272a5b0bb9f7f5965d457e1bd20c9213
7
+ data.tar.gz: 79427cf14e906ba5d800a389f410627dcf5da884090e3e324ea31ac3d22ca0b89e8ed5f024a8dd1ff8b8f51f02eb9430cd2af6ec730e6e3bcf46f2a782ac8035
@@ -0,0 +1 @@
1
+ service_name: travis-pro
data/.gitignore CHANGED
@@ -14,3 +14,5 @@
14
14
  mkmf.log
15
15
  *.sublime-project
16
16
  *.sublime-workspace
17
+
18
+ .DS_Store
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 1.9
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - ruby-head
9
+ - jruby-19mode
10
+ script: "bundle exec rake test"
11
+ notifications:
12
+ slack: accessdevelopment:ROQuruk7tsHBNDHZ1kGoXvdl
@@ -0,0 +1,7 @@
1
+ guard :minitest do
2
+ # with Minitest::Unit
3
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
4
+ watch(%r{^test/(.*)\/?(.*)_test\.rb$})
5
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
6
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
7
+ end
data/README.md CHANGED
@@ -7,7 +7,7 @@ A ruby wrapper for the Access API
7
7
  ## Installation
8
8
 
9
9
  ```ruby
10
- gem 'access'
10
+ gem 'access', '~> 2.0.0'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -25,16 +25,15 @@ Or install it yourself as:
25
25
  You can configure the following options:
26
26
 
27
27
  - `access_token` **Required**
28
- - `format`: Set as `'json'` or `'xml'`. Default is `'json'`
29
- - `api_environment`: Set as `'staging'` or `'production'`. Default is `'staging'`
30
- - `api_version`: `'v1'` is default.
31
- - `hashify` Returns the results all using Hashie::Mash if `'true'`, Default is `'false'`
28
+ - `api_environment`: Set as `'demo'` or `'production'`. Default is `'demo'`
29
+ - `return_json`: Set as `'true'` or `'false'`. Default is `'false'` return ruby objects.
30
+ - `hashify`: Set as `'true'` or `'false'`. Default is `'false'` return a hashed version of the json response if `return_json` is set to 'true'
32
31
 
33
32
  #### Config via Environment Variables
34
33
 
35
34
  You can set config settings by creating environment variables called:
36
35
 
37
- `ENV['ACCESS_TOKEN']`, `ENV['ACCESS_FORMAT']`, `ENV['ACCESS_ENVIRONMENT']`, `ENV['ACCESS_VERSION']`, `ENV['ACCESS_HASHIFY']`
36
+ `ENV['ACCESS_TOKEN']`, `ENV['ACCESS_ENVIRONMENT']`, `ENV['ACCESS_RETURN_JSON']`, `ENV['ACCESS_HASHIFY']`
38
37
 
39
38
  #### Config via Initializer
40
39
 
@@ -43,88 +42,218 @@ You can also create an initializer file to set up a config
43
42
  ```ruby
44
43
  Access.configure do |config|
45
44
  config.access_token = ENV['ACCESS_TOKEN']
46
- config.hashify = 'true'
47
45
  end
48
46
  ```
49
47
 
50
48
  You can also set them one at a time
51
49
 
52
- `Access.config.format = 'xml'`
50
+ `Access.config.access_token = ENV['ACCESS_TOKEN']`
51
+
52
+ ### Config via Params
53
+
54
+ `return_json` can be overwritten by passing in by passing the param `return_json` to the end of any call that accepts options.
55
+
56
+ `hashify` can be overwritten by passing in by passing the param `hashify` to the end of any call that accepts options.
53
57
 
54
58
  ###Making Calls
55
59
 
56
60
  ####Offer
57
61
 
58
62
  ```ruby
59
- Access::Offer.search options
63
+ Access::Offer.search options, member_key: **your-member-key**
60
64
  ```
61
65
 
62
66
  ```ruby
63
- Access::Offer.find **offer_key** options, member_key: **your-member-key**
67
+ Access::Offer.find **offer_key**, options, member_key: **your-member-key**
64
68
  ```
65
69
 
66
70
  ####Store
67
71
 
68
72
  ```ruby
69
- Access::Store.search options
73
+ Access::Store.search options, member_key: **your-member-key**
70
74
  ```
71
75
 
72
76
  ```ruby
73
- Access::Store.find store_key options
77
+ Access::Store.find **store_key**, options, member_key: **your-member-key**
78
+ ```
79
+
80
+ ```ruby
81
+ Access::Store.national options, member_key: **your-member-key**
74
82
  ```
75
83
 
76
84
  ####Location
77
85
 
78
86
  ```ruby
79
- Access::Location.search options
87
+ Access::Location.search options, member_key: **your-member-key**
80
88
  ```
81
89
 
82
90
  ```ruby
83
- Access::Location.find location_key options
91
+ Access::Location.find **location_key**, options, member_key: **your-member-key**
84
92
  ```
85
93
 
86
94
  ####Category
87
95
 
88
96
  ```ruby
89
- Access::Category.search options
97
+ Access::Category.search options, member_key: **your-member-key**
98
+ ```
99
+
100
+ ```ruby
101
+ Access::Category.find **category_key**, options, member_key: **your-member-key**
102
+ ```
103
+
104
+ ####Autocomplete
105
+
106
+ ```ruby
107
+ Access::Autocomplete.search options
108
+ ```
109
+
110
+ ```ruby
111
+ Access::Autocomplete.search_stores options
112
+ ```
113
+
114
+ ```ruby
115
+ Access::Autocomplete.search_categories options
116
+ ```
117
+
118
+ ```ruby
119
+ Access::Autocomplete.search_offers options
120
+ ```
121
+
122
+ ```ruby
123
+ Access::Autocomplete.search_locations options
124
+ ```
125
+
126
+ ####Redeem
127
+
128
+ ```ruby
129
+ Access::Redeem.redeem_offer **key**, nil, options, member_key: **your-member-key**
130
+ ```
131
+
132
+ ```ruby
133
+ Access::Redeem.redeem_offer **offer_key**, **redeem_type**, options, member_key: **your-member-key**
134
+ ```
135
+
136
+ ####Member
137
+
138
+ ####City Savings
139
+
140
+ ```ruby
141
+ Access::CitySavings.search_city_savings options, member_key: **your-member-key**
142
+ ```
143
+
144
+ ####Channel
145
+
146
+ ```ruby
147
+ Access::Channel.search options
148
+ ```
149
+
150
+ ```ruby
151
+ Access::Channel.find **channel_key**, options
152
+ ```
153
+
154
+ ####Campaign
155
+
156
+ ```ruby
157
+ Access::Campaign.search options
90
158
  ```
91
159
 
92
160
  ```ruby
93
- Access::Category.find key options
161
+ Access::Campaign.find **campaign_key**, options
162
+ ```
163
+
164
+ ###Spot
165
+
166
+ ```ruby
167
+ Access::Spot.search_by_channel **channel_key**, options
168
+ ```
169
+
170
+ ```ruby
171
+ Access::Spot.search_by_campaign **campaign_key**, options
172
+ ```
173
+
174
+ ```ruby
175
+ Access::Spot.find **spot_key**, options
176
+ ```
177
+
178
+ ###Internal Admin only Calls
179
+
180
+ ###Filter
181
+
182
+ ```ruby
183
+ Access::Filter.search options
184
+ ```
185
+
186
+ ```ruby
187
+ Access::Filter.find **filter_key**, options
94
188
  ```
95
189
 
96
190
  ####Report
97
191
 
192
+ ```ruby
193
+ Access::Report.all_usage options
194
+ ```
195
+
98
196
  ```ruby
99
197
  Access::Report.usage options
100
198
  ```
101
199
 
102
200
  ```ruby
103
- Access::Report.usage token options
201
+ Access::Report.usage_other **token**, options
104
202
  ```
105
203
 
106
204
  ####Token
107
205
 
108
206
  ```ruby
109
- Access::Token.verify options
207
+ Access::Token.search options
110
208
  ```
111
209
 
112
210
  ```ruby
113
- Access::Token.verify_other token options
211
+ Access::Token.find **token**, options
114
212
  ```
115
213
 
116
- ####Redeem
214
+ ####Oauth Application
117
215
 
118
216
  ```ruby
119
- Access::Redeem.redeem_offer key nil options` *member_key required
217
+ Access::OauthApplication.search options
120
218
  ```
121
219
 
122
220
  ```ruby
123
- Access::Redeem.redeem_offer key redeem_type options` *member_key required
221
+ Access::OauthApplication.find **application_id**, options
124
222
  ```
125
223
 
126
- ####Member
224
+ ```ruby
225
+ Access::OauthApplication.search_tokens **application_id**, options
226
+ ```
227
+
228
+ ```ruby
229
+ Access::OauthApplication.find_token **application_id**, **token_id**, options
230
+ ```
231
+
232
+ ```ruby
233
+ Access::OauthApplication.create_token **application_id**, options
234
+ ```
235
+
236
+ ```ruby
237
+ Access::OauthApplication.create **application_id**, options
238
+ ```
239
+
240
+ ```ruby
241
+ Access::OauthApplication.update **application_id**, options
242
+ ```
243
+
244
+ ```ruby
245
+ Access::OauthApplication.delete **application_id**, options
246
+ ```
247
+
248
+ ####Verify
249
+
250
+ ```ruby
251
+ Access::Verify.token options
252
+ ```
127
253
 
254
+ ```ruby
255
+ Access::Verify.filter options
256
+ ```
128
257
 
129
258
  ## Contributing
130
259
 
@@ -134,5 +263,12 @@ Access::Redeem.redeem_offer key redeem_type options` *member_key required
134
263
  4. Push to the branch (`git push origin my-new-feature`)
135
264
  5. Create a new Pull Request
136
265
 
266
+ ### Running the Tests
267
+
268
+ `ACCESS_TOKEN=**your-access-token** rake`
269
+
270
+ `ACCESS_TOKEN=*your-access-token** guard`
137
271
 
272
+ ### Running the Gem in Console
138
273
 
274
+ `ACCESS_TOKEN=*your-access-token** ruby bin/console`
data/Rakefile CHANGED
@@ -1,2 +1,15 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
2
3
 
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task default: :test
12
+
13
+ task :clear_vcr do
14
+ `rm test/fixtures/*.yml`
15
+ end
@@ -24,7 +24,12 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "vcr"
25
25
  spec.add_development_dependency "webmock"
26
26
  spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "guard"
28
+ spec.add_development_dependency "guard-minitest"
29
+ spec.add_development_dependency "coveralls"
30
+ spec.add_development_dependency "simplecov"
31
+ spec.add_development_dependency "minitest-focus"
27
32
 
28
- spec.add_dependency "httparty", "~> 0.13.3"
29
33
  spec.add_dependency "hashie", "~> 3.3.1"
34
+ spec.add_dependency "httparty", "~> 0.13.3"
30
35
  end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "access"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -2,23 +2,34 @@ require "rubygems"
2
2
  require "hashie"
3
3
  require "httparty"
4
4
 
5
- require "access/version"
6
- require "access/error"
7
5
  require "access/config"
8
- require "access/request"
9
6
  require "access/api"
10
- require "access/offer"
11
- require "access/store"
12
- require "access/location"
13
- require "access/category"
14
7
  require "access/autocomplete"
15
- require "access/report"
8
+ require "access/campaign"
9
+ require "access/category"
10
+ require "access/channel"
11
+ require "access/city_savings"
12
+ require "access/error"
16
13
  require "access/filter"
14
+ require "access/info"
15
+ require "access/link"
16
+ require "access/location"
17
+ require "access/member"
17
18
  require "access/oauth_application"
19
+ require "access/offer"
20
+ require "access/redeem"
21
+ require "access/report"
22
+ require "access/request"
23
+ require "access/response"
24
+ require "access/spot"
25
+ require "access/store"
18
26
  require "access/token"
19
27
  require "access/verify"
20
- require "access/redeem"
21
- # require "access/member"
28
+ require "access/version"
29
+
30
+ module Access
31
+
32
+ end
22
33
 
23
34
  HTTParty::Response.class_eval do
24
35
  def hashify
@@ -1,145 +1,269 @@
1
1
  module Access
2
- class Api < Request
2
+ class Api
3
3
 
4
4
  # Categories
5
5
  def search_categories(options = {})
6
- get("/categories", "offer", options)
6
+ request.get("/categories", "offer", options) do |response|
7
+ CategoryResponse.new(response)
8
+ end
7
9
  end
8
10
 
9
- def find_category(category_id, options = {})
10
- get("/categories/#{category_id}", "offer", options)
11
+ def find_category(category_key, options = {})
12
+ request.get("/categories/#{category_key}", "offer", options) do |response|
13
+ CategoryResponse.new(response)
14
+ end
11
15
  end
12
16
 
13
-
14
17
  # Offers
15
- def search_offers(options={})
16
- get("/offers", "offer", options)
18
+ def search_offers(options = {})
19
+ request.get("/offers", "offer", options) do |response|
20
+ OfferResponse.new(response)
21
+ end
17
22
  end
18
23
 
19
- def find_offer(offer_id, options = {})
20
- get("/offers/#{offer_id}", "offer", options)
24
+ def find_offer(offer_key, options = {})
25
+ request.get("/offers/#{offer_key}", "offer", options) do |response|
26
+ OfferResponse.new(response)
27
+ end
21
28
  end
22
29
 
23
-
24
30
  # Locations
25
- def search_locations(options={})
26
- get("/locations", "offer", options)
31
+ def search_locations(options = {})
32
+ request.get("/locations", "offer", options) do |response|
33
+ LocationResponse.new(response)
34
+ end
27
35
  end
28
36
 
29
- def find_location(location_id, options = {})
30
- get("/locations/#{location_id}", "offer", options)
37
+ def find_location(location_key, options = {})
38
+ request.get("/locations/#{location_key}", "offer", options) do |response|
39
+ LocationResponse.new(response)
40
+ end
31
41
  end
32
42
 
33
-
34
43
  # Stores
35
- def search_stores(options={})
36
- get("/stores", "offer", options)
44
+ def search_stores(options = {})
45
+ request.get("/stores", "offer", options) do |response|
46
+ StoreResponse.new(response)
47
+ end
37
48
  end
38
49
 
39
- def find_store(store_id, options = {})
40
- get("/stores/#{store_id}", "offer", options)
50
+ def find_store(store_key, options = {})
51
+ request.get("/stores/#{store_key}", "offer", options) do |response|
52
+ StoreResponse.new(response)
53
+ end
41
54
  end
42
55
 
43
56
  def national_stores(options={})
44
- get("/stores/national", "offer", options)
57
+ request.get("/stores/national", "offer", options) do |response|
58
+ StoreResponse.new(response)
59
+ end
45
60
  end
46
61
 
47
-
48
62
  # Autocomplete
49
63
  def autocomplete(options = {})
50
- get("/autocomplete", "offer", options)
64
+ request.get("/autocomplete", "offer", options) do |response|
65
+ AutocompleteResponse.new(response)
66
+ end
51
67
  end
52
68
 
69
+ # Redeem
70
+ def redeem_offer(offer_key, redeem_type = nil, options = {})
71
+ request.get("/redeem/#{offer_key}/#{redeem_type}", "redeem", options) do |response|
72
+ RedeemResponse.new(response)
73
+ end
74
+ end
53
75
 
54
- # Filters
55
- def search_filters(options = {})
56
- get('/filters', 'token', options)
76
+ # CitySavings
77
+ def search_city_savings(options = {})
78
+ # this is broken
79
+ request.get("/citysavings", "allcitysavings", options) do |response|
80
+ CitySavingsResponse.new(response)
81
+ end
82
+ end
83
+
84
+ # Channel
85
+ def search_channels(options = {})
86
+ request.get("/channels", "campaign", options) do |response|
87
+ ChannelResponse.new(response)
88
+ end
57
89
  end
58
90
 
59
- def find_filter(application_id, options = {})
60
- get("/filters/#{application_id}", 'token', options)
91
+ def find_channel(channel_key, options = {})
92
+ request.get("/channels/#{channel_key}", "campaign", options) do |response|
93
+ ChannelResponse.new(response)
94
+ end
61
95
  end
62
96
 
97
+ # Campaign
98
+ def search_campaigns(options = {})
99
+ request.get("/campaigns", "campaign", options) do |response|
100
+ ChampaignResponse.new(response)
101
+ end
102
+ end
63
103
 
64
- # Oauth Applications
65
- def search_oauth_applications(options = {})
66
- get('/oauth_applications', 'token', options)
104
+ def find_campaign(campaign_key, options = {})
105
+ request.get("/campaigns/#{store_key}", "campaign", options) do |response|
106
+ ChampaignResponse.new(response)
107
+ end
67
108
  end
68
109
 
69
- def find_oauth_application(application_id, options = {})
70
- get("/oauth_applications/#{application_id}", 'token', options)
110
+ # Spot
111
+ def search_spots_by_channel(channel_key, options = {})
112
+ request.get("/spots/channel/#{channel_key}", "campaign", options) do |response|
113
+ SpotResponse.new(response)
114
+ end
71
115
  end
72
116
 
73
- def search_oauth_application_tokens(application_id, options = {})
74
- get("/oauth_applications/#{application_id}/access_tokens", 'token', options)
117
+ def search_spots_by_campaign(campaign_key, options = {})
118
+ request.get("/spots/campaign/#{campaign_key}", "campaign", options) do |response|
119
+ SpotResponse.new(response)
120
+ end
75
121
  end
76
122
 
77
- def find_oauth_application_token(application_id, token_id, options = {})
78
- get("/oauth_applications/#{application_id}/access_tokens/#{token_id}", 'token', options)
123
+ def find_spot(spot_key, options = {})
124
+ request.get("/spots/#{spot_key}", "campaign", options) do |response|
125
+ SpotResponse.new(response)
126
+ end
79
127
  end
80
128
 
81
- def create_oauth_application_token(application_id, options = {})
82
- create("/oauth_applications/#{application_id}/access_tokens", 'token', options)
129
+ # Member
130
+
131
+ # Internal Admin only Call Below
132
+
133
+ # Filters
134
+ def search_filters(options = {})
135
+ # Internal Admin only Call
136
+ request.get("/filters", "token", options) do |response|
137
+ FilterResponse.new(response)
138
+ end
83
139
  end
84
140
 
85
- def create_oauth_application(options = {})
86
- create("/oauth_applications", 'token', options)
141
+ def find_filter(application_key, options = {})
142
+ # Internal Admin only Call
143
+ request.get("/filters/#{application_key}", "token", options) do |response|
144
+ FilterResponse.new(response)
145
+ end
87
146
  end
88
147
 
89
- def update_oauth_application(application_id, options = {})
90
- put("/oauth_applications/#{application_id}", 'token', options)
148
+ # Oauth Applications
149
+ def search_oauth_applications(options = {})
150
+ # Internal Admin only Call
151
+ request.get("/oauth_applications", 'token', options) do |response|
152
+ OauthApplicationResponse.new(response)
153
+ end
91
154
  end
92
155
 
93
- def delete_oauth_application(application_id, options = {})
94
- delete("/oauth_applications/#{application_id}", 'token', options)
156
+ def find_oauth_application(application_key, options = {})
157
+ # Internal Admin only Call
158
+ request.get("/oauth_applications/#{application_key}", 'token', options) do |response|
159
+ OauthApplicationResponse.new(response)
160
+ end
95
161
  end
96
162
 
163
+ def search_oauth_application_tokens(application_key, options = {})
164
+ # Internal Admin only Call
165
+ request.get("/oauth_applications/#{application_key}/access_tokens", 'token', options) do |response|
166
+ TokenResponse.new(response)
167
+ end
168
+ end
97
169
 
98
- # Access Tokens
99
- def search_tokens(options = {})
100
- get('/tokens', 'token', options)
170
+ def find_oauth_application_token(application_key, token_key, options = {})
171
+ # Internal Admin only Call
172
+ request.get("/oauth_applications/#{application_key}/access_tokens/#{token_key}", 'token', options) do |response|
173
+ TokenResponse.new(response)
174
+ end
101
175
  end
102
176
 
103
- def find_token(token, options = {}) # new verify_other
104
- get("/tokens/#{token}", "token", options)
177
+ def create_oauth_application_token(application_key, options = {})
178
+ # Internal Admin only Call
179
+ request.create("/oauth_applications/#{application_key}/access_tokens", 'token', options) do |response|
180
+ # TokenResponse.new(response)
181
+ # OauthApplicationResponse.new(response)
182
+ end
183
+ # create("/oauth_applications/#{application_key}/access_tokens", 'token', options)
105
184
  end
106
185
 
186
+ def create_oauth_application(options = {})
187
+ # Internal Admin only Call
188
+ request.create("/oauth_applications", 'token', options) do |response|
189
+ OauthApplicationResponse.new(response)
190
+ end
191
+ # create("/oauth_applications", 'token', options)
192
+ end
107
193
 
108
- # Verify
109
- def verify_token(options = {})
110
- get('/verify', 'token', options)
194
+ def update_oauth_application(application_key, batch= {})
195
+ # Internal Admin only Call
196
+ request.put("/oauth_applications/#{application_key}", 'token', options) do |response|
197
+ OauthApplicationResponse.new(response)
198
+ end
199
+ # put("/oauth_applications/#{application_key}", 'token', options)
111
200
  end
112
201
 
113
- def verify_filter(options = {})
114
- get_json('/filter', 'token', options)
202
+ def delete_oauth_application(application_key, options = {})
203
+ # Internal Admin only Call
204
+ request.delete("/oauth_applications/#{application_key}", 'token', options) do |response|
205
+ OauthApplication.new(response)
206
+ end
207
+ # delete("/oauth_applications/#{application_key}", 'token', options)
115
208
  end
116
209
 
210
+ # Access Tokens
211
+ def search_tokens(options = {})
212
+ # Internal Admin only Call
213
+ request.get("/tokens", 'token', options) do |response|
214
+ TokenResponse.new(response)
215
+ end
216
+ end
117
217
 
118
- # Redeem
119
- def redeem_offer(offer_key, redeem_type = nil, options = {})
120
- get("/redeem/#{offer_key}/#{redeem_type}", "redeem", options)
218
+ def find_token(token, options = {})
219
+ # Internal Admin only Call
220
+ # new verify_other
221
+ request.get("/tokens/#{token}", "token", options) do |response|
222
+ TokenResponse.new(response)
223
+ end
121
224
  end
122
225
 
123
- def citysavings(options = {})
124
- get("/citysavings", "allcitysavings", options)
226
+ # Verify
227
+ def verify_token(options = {})
228
+ # Internal Admin only Call
229
+ request.get("/verify", 'token', options) do |response|
230
+ VerifyResponse.new(response)
231
+ end
125
232
  end
126
233
 
234
+ def verify_filter(filter, options = {})
235
+ # Internal Admin only Call
236
+ request.get_for_filter("/filter", 'token', filter, options) do |response|
237
+ VerifyResponse.new(response)
238
+ end
239
+ end
127
240
 
128
241
  # Report
129
242
  def all_usage(options = {})
130
- get("/all_usage", "report", options)
243
+ # Internal Admin only Call
244
+ request.get("/all_usage", "report", options) do |response|
245
+ ReportResponse.new(response)
246
+ end
131
247
  end
132
248
 
133
249
  def usage(options = {})
134
- get("/usage", "report", options)
250
+ # Internal Admin only Call
251
+ request.get("/usage", "report", options) do |response|
252
+ ReportResponse.new(response)
253
+ end
135
254
  end
136
255
 
137
256
  def usage_other(token, options = {})
138
- get("/usage/#{token}", "report", options)
257
+ # Internal Admin only Call
258
+ request.get("/usage/#{token}", "report", options) do |response|
259
+ ReportResponse.new(response)
260
+ end
139
261
  end
140
262
 
263
+ private
141
264
 
142
- # Member
143
-
265
+ def request
266
+ Access::Request.new
267
+ end
144
268
  end
145
269
  end