access 1.1.7 → 2.0.0
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.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/Guardfile +7 -0
- data/README.md +159 -23
- data/Rakefile +13 -0
- data/access.gemspec +6 -1
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/access.rb +21 -10
- data/lib/access/api.rb +188 -64
- data/lib/access/autocomplete.rb +11 -0
- data/lib/access/campaign.rb +24 -0
- data/lib/access/category.rb +16 -2
- data/lib/access/channel.rb +24 -0
- data/lib/access/city_savings.rb +16 -0
- data/lib/access/config.rb +8 -7
- data/lib/access/error.rb +8 -2
- data/lib/access/filter.rb +30 -2
- data/lib/access/info.rb +13 -0
- data/lib/access/link.rb +17 -0
- data/lib/access/location.rb +17 -2
- data/lib/access/member.rb +11 -0
- data/lib/access/oauth_application.rb +31 -0
- data/lib/access/offer.rb +24 -20
- data/lib/access/redeem.rb +11 -4
- data/lib/access/report.rb +10 -0
- data/lib/access/request.rb +25 -20
- data/lib/access/response.rb +127 -0
- data/lib/access/spot.rb +28 -0
- data/lib/access/store.rb +16 -2
- data/lib/access/token.rb +18 -0
- data/lib/access/verify.rb +11 -2
- data/lib/access/version.rb +1 -1
- data/test/access/autocomplete_test.rb +53 -0
- data/test/access/category_test.rb +64 -0
- data/test/access/city_savings_test.rb +5 -0
- data/test/access/filter_test.rb +40 -0
- data/test/access/location_test.rb +59 -0
- data/test/access/member_test.rb +5 -0
- data/test/access/oauth_application_test.rb +91 -0
- data/test/access/offer_test.rb +71 -0
- data/test/access/redeem_test.rb +38 -0
- data/test/access/report_test.rb +36 -0
- data/test/access/store_test.rb +65 -0
- data/test/access/token_test.rb +35 -0
- data/test/access/verify_test.rb +29 -0
- data/test/access/version_test.rb +9 -0
- data/test/fixtures/autocomplete_search.yml +207 -0
- data/test/fixtures/autocomplete_search_categories.yml +181 -0
- data/test/fixtures/autocomplete_search_locations.yml +173 -0
- data/test/fixtures/autocomplete_search_offers.yml +181 -0
- data/test/fixtures/autocomplete_search_stores.yml +185 -0
- data/test/fixtures/category_find.yml +303 -0
- data/test/fixtures/category_search.yml +683 -0
- data/test/fixtures/category_search_fail_member_key.yml +102 -0
- data/test/fixtures/filter_find.yml +70 -0
- data/test/fixtures/filter_search.yml +195 -0
- data/test/fixtures/location_find.yml +923 -0
- data/test/fixtures/location_search.yml +378 -0
- data/test/fixtures/location_search_fail_member_key.yml +367 -0
- data/test/fixtures/national_stores.yml +4135 -0
- data/test/fixtures/oauth_application_find.yml +163 -0
- data/test/fixtures/oauth_application_search.yml +134 -0
- data/test/fixtures/oauth_application_search_fail_member_key.yml +268 -0
- data/test/fixtures/oauth_application_token_find.yml +249 -0
- data/test/fixtures/oauth_application_token_search.yml +98 -0
- data/test/fixtures/offer_find.yml +683 -0
- data/test/fixtures/offer_search.yml +329 -0
- data/test/fixtures/offer_search_fail_member_key.yml +102 -0
- data/test/fixtures/redeem_offer_no_redeem_type.yml +423 -0
- data/test/fixtures/store_find.yml +333 -0
- data/test/fixtures/store_search.yml +227 -0
- data/test/fixtures/store_search_fail_member_key.yml +102 -0
- data/test/fixtures/subcategory_find.yml +283 -0
- data/test/fixtures/token_find.yml +245 -0
- data/test/fixtures/token_search.yml +301 -0
- data/test/fixtures/verify_filter.yml +290 -0
- data/test/fixtures/verify_token.yml +78 -0
- data/test/test_helper.rb +15 -0
- metadata +183 -11
- data/test/offers/offer_test.rb +0 -5
data/lib/access/autocomplete.rb
CHANGED
@@ -21,5 +21,16 @@ module Access
|
|
21
21
|
Access::Api.new.autocomplete options.merge(resources: 'locations')
|
22
22
|
end
|
23
23
|
|
24
|
+
def initialize(values)
|
25
|
+
self.class.class_eval {attr_reader *values.keys }
|
26
|
+
values.each do |attribute_name, attribute_value|
|
27
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
28
|
+
end
|
29
|
+
@offers = Access::Offer.process_batch(@offers) if @offers
|
30
|
+
@stores = Access::Store.process_batch(@stores) if @stores
|
31
|
+
@locations = Access::Location.process_batch(@locations) if @locations
|
32
|
+
@categories = Access::Category.process_batch(@categories) if @categories
|
33
|
+
end
|
34
|
+
|
24
35
|
end
|
25
36
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Access
|
2
|
+
class Campaign
|
3
|
+
|
4
|
+
def self.search(options = {})
|
5
|
+
Access::api.new.search_campaigns options
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(campaign_key, options = {})
|
9
|
+
Access::api.new.find_campaign campaign_key, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.process_batch(chunk)
|
13
|
+
chunk.map { |campaign| new(campaign) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(values)
|
17
|
+
self.class.class_eval {attr_reader *values.keys }
|
18
|
+
values.each do |attribute_name, attribute_value|
|
19
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/access/category.rb
CHANGED
@@ -5,8 +5,22 @@ module Access
|
|
5
5
|
Access::Api.new.search_categories options
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.find(
|
9
|
-
Access::Api.new.find_category
|
8
|
+
def self.find(category_key, options = {})
|
9
|
+
Access::Api.new.find_category category_key, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.process_batch(chunk)
|
13
|
+
chunk.map { |category| new(category) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(values)
|
17
|
+
self.class.class_eval {attr_reader *values.keys }
|
18
|
+
values.each do |attribute_name, attribute_value|
|
19
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
20
|
+
end
|
21
|
+
@links = Access::Link.new(@links) if @links
|
22
|
+
@subcategories = Access::Category.process_batch(@subcategories) if @subcategories
|
23
|
+
@subcategory_siblings = Access::Category.process_batch(@subcategory_siblings) if @subcategory_siblings
|
10
24
|
end
|
11
25
|
|
12
26
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Access
|
2
|
+
class Channel
|
3
|
+
|
4
|
+
def self.search(options = {})
|
5
|
+
Access::Api.new.search_channels options
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(channel_key, options = {})
|
9
|
+
Access::Api.new.find_channel channel_key, options
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.process_batch(chunk)
|
13
|
+
chunk.map { |campaign| new(campaign) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(values)
|
17
|
+
self.class.class_eval {attr_reader *values.keys }
|
18
|
+
values.each do |attribute_name, attribute_value|
|
19
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Access
|
2
|
+
class CitySavings
|
3
|
+
|
4
|
+
def self.search(options = {})
|
5
|
+
Access::Api.new.search_city_savings options
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(values)
|
9
|
+
self.class.class_eval {attr_reader *values.keys }
|
10
|
+
values.each do |attribute_name, attribute_value|
|
11
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/access/config.rb
CHANGED
@@ -14,23 +14,24 @@ module Access
|
|
14
14
|
|
15
15
|
class Config
|
16
16
|
DOMAINS = {'production' => '', 'demo' => '-demo', 'stage' => '-stage', 'staging' => '-stage' }
|
17
|
-
attr_accessor :access_token, :
|
17
|
+
attr_accessor :access_token, :api_environment, :return_json, :hashify
|
18
18
|
|
19
19
|
def initialize
|
20
20
|
@access_token = ENV['ACCESS_TOKEN']
|
21
|
-
@format = ENV['ACCESS_FORMAT'] || 'json'
|
22
21
|
# demo, stage, production
|
23
22
|
@api_environment = ENV['ACCESS_ENVIRONMENT'] || 'demo'
|
24
|
-
@api_version = ENV['ACCESS_VERSION'] || 'v1'
|
23
|
+
# @api_version = ENV['ACCESS_VERSION'] || 'v1'
|
24
|
+
@return_json = ENV['ACCESS_RETURN_JSON'] || 'false'
|
25
|
+
# only used when return_json is true
|
25
26
|
@hashify = ENV['ACCESS_HASHIFY'] || 'false'
|
26
27
|
end
|
27
28
|
|
28
29
|
def reset
|
29
30
|
self.access_token = ENV['ACCESS_TOKEN']
|
30
|
-
self.
|
31
|
-
self.
|
32
|
-
self.
|
33
|
-
self.hashify = false
|
31
|
+
self.api_environment = ENV['ACCESS_ENVIRONMENT'] || 'demo'
|
32
|
+
# self.api_version = 'v1'
|
33
|
+
self.return_json = ENV['ACCESS_RETURN_JSON'] || 'false'
|
34
|
+
self.hashify = ENV['ACCESS_HASHIFY'] || 'false'
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
data/lib/access/error.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module Access
|
2
|
-
|
3
|
-
|
2
|
+
class Error
|
4
3
|
class AuthenticationError < StandardError; end
|
5
4
|
class NoAccessToken < AuthenticationError; end
|
6
5
|
class InvalidResponseFormat < TypeError; end
|
7
6
|
|
7
|
+
attr_reader :message, :status_code, :status
|
8
|
+
|
9
|
+
def initialize(response_status, response_code, response_message = nil)
|
10
|
+
@status_code = response_code
|
11
|
+
@status = response_status
|
12
|
+
@message = response_message
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
|
data/lib/access/filter.rb
CHANGED
@@ -2,12 +2,40 @@ module Access
|
|
2
2
|
class Filter
|
3
3
|
|
4
4
|
def self.search(options = {})
|
5
|
+
# Internal Admin only Call
|
5
6
|
Access::Api.new.search_filters options
|
6
7
|
end
|
7
8
|
|
8
|
-
def self.find(
|
9
|
-
|
9
|
+
def self.find(filter_key, options = {})
|
10
|
+
# Internal Admin only Call
|
11
|
+
Access::Api.new.find_filter filter_key, options
|
10
12
|
end
|
11
13
|
|
14
|
+
def self.process_batch(chunk)
|
15
|
+
chunk.map { |filter| new(filter) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(values)
|
19
|
+
self.class.class_eval { attr_reader *values.keys }
|
20
|
+
values.each do |attribute_name, attribute_value|
|
21
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def filter_key
|
26
|
+
@filter_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def name
|
30
|
+
@filter_name
|
31
|
+
end
|
32
|
+
|
33
|
+
def json_filter
|
34
|
+
YAML::load(@filter).to_json if @filter
|
35
|
+
end
|
36
|
+
|
37
|
+
def hash_filter
|
38
|
+
YAML::load(@filter).to_hash if @filter
|
39
|
+
end
|
12
40
|
end
|
13
41
|
end
|
data/lib/access/info.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Access
|
2
|
+
class Info
|
3
|
+
|
4
|
+
def initialize(values)
|
5
|
+
self.class.class_eval {attr_reader *values.keys }
|
6
|
+
values.each do |attribute_name, attribute_value|
|
7
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/lib/access/link.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Access
|
2
|
+
class Link
|
3
|
+
|
4
|
+
def self.process_batch(chunk)
|
5
|
+
chunk.map { |link| new(link) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(values)
|
9
|
+
self.class.class_eval {attr_reader *values.keys }
|
10
|
+
values.each do |attribute_name, attribute_value|
|
11
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/lib/access/location.rb
CHANGED
@@ -5,9 +5,24 @@ module Access
|
|
5
5
|
Access::Api.new.search_locations options
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.find(
|
9
|
-
Access::Api.new.find_location
|
8
|
+
def self.find(location_key, options = {})
|
9
|
+
Access::Api.new.find_location location_key, options
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.process_batch(chunk)
|
13
|
+
chunk.map { |location| new(location) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(values)
|
17
|
+
self.class.class_eval {attr_reader *values.keys } if values
|
18
|
+
values.each do |attribute_name, attribute_value|
|
19
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
20
|
+
end
|
21
|
+
|
22
|
+
@links = Access::Link.new(@links) if @links
|
23
|
+
@location_store = Access::Store.new(@location_store) if @location_store
|
24
|
+
@location_categories = Access::Category.process_batch(@location_categories) if @location_categories
|
25
|
+
@physical_location = Access::Location.new(@physical_location) if @physical_location
|
26
|
+
end
|
12
27
|
end
|
13
28
|
end
|
data/lib/access/member.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
module Access
|
2
2
|
class Member
|
3
3
|
|
4
|
+
def self.process_batch(chunk)
|
5
|
+
chunk.map { |member| new(member) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(values)
|
9
|
+
self.class.class_eval {attr_reader *values.keys }
|
10
|
+
values.each do |attribute_name, attribute_value|
|
11
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
end
|
5
16
|
end
|
@@ -2,36 +2,67 @@ module Access
|
|
2
2
|
class OauthApplication
|
3
3
|
|
4
4
|
def self.search(options = {})
|
5
|
+
# Internal Admin only Call
|
5
6
|
Access::Api.new.search_oauth_applications options
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.find(application_id, options = {})
|
10
|
+
# Internal Admin only Call
|
9
11
|
Access::Api.new.find_oauth_application application_id, options
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.search_tokens(application_id, options = {})
|
15
|
+
# Internal Admin only Call
|
16
|
+
# Returns Token Response
|
13
17
|
Access::Api.new.search_oauth_application_tokens application_id, options
|
14
18
|
end
|
15
19
|
|
16
20
|
def self.find_token(application_id, token_id, options = {})
|
21
|
+
# Internal Admin only Call
|
22
|
+
# Returns Token Response
|
17
23
|
Access::Api.new.find_oauth_application_token application_id, token_id, options
|
18
24
|
end
|
19
25
|
|
20
26
|
def self.create_token(application_id, options = {})
|
27
|
+
# Internal Admin only Call
|
21
28
|
Access::Api.new.create_oauth_application_token application_id, options
|
22
29
|
end
|
23
30
|
|
24
31
|
def self.create(options = {})
|
32
|
+
# Internal Admin only Call
|
25
33
|
Access::Api.new.create_oauth_application options
|
26
34
|
end
|
27
35
|
|
28
36
|
def self.update(application_id, options = {})
|
37
|
+
# Internal Admin only Call
|
29
38
|
Access::Api.new.update_oauth_application application_id, options
|
30
39
|
end
|
31
40
|
|
32
41
|
def self.delete(application_id, options = {})
|
42
|
+
# Internal Admin only Call
|
33
43
|
Access::Api.new.delete_oauth_application application_id, options
|
34
44
|
end
|
35
45
|
|
46
|
+
def self.process_batch(chunk)
|
47
|
+
chunk.map { |application| new(application) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def initialize(values)
|
51
|
+
self.class.class_eval {attr_reader *values.keys }
|
52
|
+
values.each do |attribute_name, attribute_value|
|
53
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
54
|
+
end
|
55
|
+
@links = Access::Link.new(@links) if @links
|
56
|
+
@filter = Access::Filter.new(@filter) if @filter
|
57
|
+
end
|
58
|
+
|
59
|
+
def has_scope?(scope)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def oauth_application_key
|
64
|
+
@id
|
65
|
+
end
|
66
|
+
|
36
67
|
end
|
37
68
|
end
|
data/lib/access/offer.rb
CHANGED
@@ -1,31 +1,35 @@
|
|
1
1
|
module Access
|
2
2
|
class Offer
|
3
|
-
|
4
|
-
# def self.search_options
|
5
|
-
# [
|
6
|
-
# { param: "query",
|
7
|
-
# description: "It does searches",
|
8
|
-
# documentation_link: "https://docs.accessdevelopment"
|
9
|
-
# }
|
10
|
-
# ]
|
11
|
-
# end
|
12
|
-
|
13
|
-
# def self.find_options
|
14
|
-
# [
|
15
|
-
# { param: "query",
|
16
|
-
# description: "It does searches",
|
17
|
-
# documentation_link: "https://docs.accessdevelopment/docs#asdfkjl"
|
18
|
-
# }
|
19
|
-
# ]
|
20
|
-
# end
|
3
|
+
attr_reader :store, :location
|
21
4
|
|
22
5
|
def self.search(options = {})
|
23
6
|
Access::Api.new.search_offers options
|
24
7
|
end
|
25
8
|
|
26
|
-
def self.find(
|
27
|
-
Access::Api.new.find_offer
|
9
|
+
def self.find(offer_key, options = {})
|
10
|
+
Access::Api.new.find_offer offer_key, options
|
28
11
|
end
|
29
12
|
|
13
|
+
def self.process_batch(chunk)
|
14
|
+
chunk.map { |offer| new(offer) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(values)
|
18
|
+
self.class.class_eval { attr_reader *values.keys }
|
19
|
+
values.each do |attribute_name, attribute_value|
|
20
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
21
|
+
end
|
22
|
+
@categories = Access::Category.process_batch(@categories) if @categories
|
23
|
+
@links = Access::Link.new(@links) if @links
|
24
|
+
@offer_store = Access::Store.new(@offer_store) if @offer_store
|
25
|
+
end
|
26
|
+
|
27
|
+
def location
|
28
|
+
@offer_store.physical_location
|
29
|
+
end
|
30
|
+
|
31
|
+
def store
|
32
|
+
@offer_store
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
data/lib/access/redeem.rb
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
module Access
|
2
2
|
class Redeem
|
3
3
|
|
4
|
-
def self.redeem_offer(
|
5
|
-
Access::Api.new.redeem_offer
|
4
|
+
def self.redeem_offer(offer_key, redeem_type = nil, options = {})
|
5
|
+
Access::Api.new.redeem_offer offer_key, redeem_type, options
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.
|
9
|
-
|
8
|
+
def self.process_batch(chunk)
|
9
|
+
chunk.map { |redeem| new(redeem) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(values)
|
13
|
+
self.class.class_eval {attr_reader *values.keys }
|
14
|
+
values.each do |attribute_name, attribute_value|
|
15
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
end
|
data/lib/access/report.rb
CHANGED
@@ -2,16 +2,26 @@ module Access
|
|
2
2
|
class Report
|
3
3
|
|
4
4
|
def self.all_usage(options = {})
|
5
|
+
# Internal Admin only Call
|
5
6
|
Access::Api.new.all_usage options
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.usage(options = {})
|
10
|
+
# Internal Admin only Call
|
9
11
|
Access::Api.new.usage options
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.usage_other(key, options = {})
|
15
|
+
# Internal Admin only Call
|
13
16
|
Access::Api.new.usage_other key, options
|
14
17
|
end
|
15
18
|
|
19
|
+
def initialize(values)
|
20
|
+
self.class.class_eval {attr_reader *values.keys }
|
21
|
+
values.each do |attribute_name, attribute_value|
|
22
|
+
self.instance_variable_set("@#{attribute_name}", attribute_value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
end
|
17
27
|
end
|