access 2.0.5 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/access.rb +1 -0
- data/lib/access/aggregations.rb +18 -0
- data/lib/access/api.rb +13 -2
- data/lib/access/member.rb +7 -0
- data/lib/access/request.rb +13 -0
- data/lib/access/response.rb +20 -3
- data/lib/access/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2143c3448ab92d8d2c6e6ef732addd98d2eadb5
|
4
|
+
data.tar.gz: 85abd3b0b5551dfcddc30f0a62c0a72215405648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 225f6b7dc3cfca5d6f58bd76ac64e07cd9d0d719ab8ffa4409da36ca7ca2696a638a6a365b0902ddf4ce64b2b837239bbcfccc4b54200cc72c8afe9f1cb81fae
|
7
|
+
data.tar.gz: 4a7c899f1eca0b78dbe64eae7ce68fc6432b2a07eff04817a9ab0420e7e5721f83819f7b6404c4172e67139fdb9c1a409a909797b6f15b0d358a1211f477de06
|
data/lib/access.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Access
|
2
|
+
class Aggregations
|
3
|
+
|
4
|
+
def self.process_batch(chunk)
|
5
|
+
chunk.map { |aggs| new(aggs) }
|
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
|
+
@subcategories = Access::Category.process_batch(@subcategories) if @subcategories
|
14
|
+
@facets = Access::Aggregations.process_batch(@facets) if @facets
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/access/api.rb
CHANGED
@@ -97,13 +97,13 @@ module Access
|
|
97
97
|
# Campaign
|
98
98
|
def search_campaigns(options = {})
|
99
99
|
request.get("/campaigns", "campaign", options) do |response|
|
100
|
-
|
100
|
+
CampaignResponse.new(response)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
def find_campaign(campaign_key, options = {})
|
105
105
|
request.get("/campaigns/#{store_key}", "campaign", options) do |response|
|
106
|
-
|
106
|
+
CampaignResponse.new(response)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -127,6 +127,17 @@ module Access
|
|
127
127
|
end
|
128
128
|
|
129
129
|
# Member
|
130
|
+
def member_registration(options = {})
|
131
|
+
request.post("/register", "mms", options) do |response|
|
132
|
+
MemberRegistrationResponse.new(response)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def member_authentication(options = {})
|
137
|
+
request.get("/auth", "mms", options) do |response|
|
138
|
+
MemberResponse.new(response)
|
139
|
+
end
|
140
|
+
end
|
130
141
|
|
131
142
|
# Internal Admin only Call Below
|
132
143
|
|
data/lib/access/member.rb
CHANGED
data/lib/access/request.rb
CHANGED
@@ -15,6 +15,19 @@ module Access
|
|
15
15
|
raise Access::Error::Timeout
|
16
16
|
end
|
17
17
|
|
18
|
+
def post(path, api_type, options={}, &block)
|
19
|
+
url = set_base(api_type, path)
|
20
|
+
results = self.class.post(url, headers: headers(options[:access_token]), body: options.to_json, timeout: (options[:access_timeout] || 10))
|
21
|
+
if should_return_json?(options[:return_json])
|
22
|
+
hashify_results?(options[:hashify]) ? results.hashify : results
|
23
|
+
else
|
24
|
+
block.call results
|
25
|
+
end
|
26
|
+
rescue Net::ReadTimeout, Net::OpenTimeout
|
27
|
+
# block.call({"message"=>"Request Timeout Error", "status"=>408})
|
28
|
+
raise Access::Error::Timeout
|
29
|
+
end
|
30
|
+
|
18
31
|
def get_for_filter(path, api_type, filter, options={}, &block)
|
19
32
|
url = set_base(api_type, path)
|
20
33
|
results = self.class.get(url, headers: headers(options[:access_token]), body: filter, timeout: (options[:access_timeout] || 3))
|
data/lib/access/response.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Access
|
2
2
|
class Response
|
3
3
|
|
4
|
-
attr_accessor :info, :offers, :stores, :locations, :categories, :suggestions, :oauth_applications, :access_tokens, :oauth_tokens, :oauth_token, :verify, :reports, :members, :filters, :links, :dev_node, :message, :status, :success, :error, :response_status, :content_type, :redemption_method, :details, :oauth_access_token, :api_calls_over_time, :member_query_terms, :member_postal_codes, :
|
4
|
+
attr_accessor :info, :offers, :stores, :locations, :categories, :suggestions, :oauth_applications, :access_tokens, :oauth_tokens, :oauth_token, :verify, :reports, :members, :filters, :links, :dev_node, :message, :status, :success, :error, :response_status, :content_type, :redemption_method, :details, :oauth_access_token, :api_calls_over_time, :member_query_terms, :member_postal_codes, :offer_count_in_categories, :offer_count_by_redemption_method, :offer_count_by_facet, :custom_aggregation, :internal_details, :users, :response
|
5
5
|
|
6
6
|
def initialize(response)
|
7
|
+
@response = response # Setting this temporarily so i can have a working member reg call, since it doesn't follow the resource [] best practices
|
7
8
|
response.each { |key, value| instance_variable_set("@#{key}", value) if self.class.instance_methods.include? key.to_sym }
|
8
9
|
@response_status = response.message
|
9
10
|
@status ||= response.code
|
@@ -37,6 +38,10 @@ module Access
|
|
37
38
|
# for when you search and it returns 0
|
38
39
|
(@offers = []; create_error) if @message
|
39
40
|
@offers = Access::Offer.process_batch(@offers)
|
41
|
+
@offer_count_in_categories = Access::Aggregations.process_batch(@offer_count_in_categories) if @offer_count_in_categories
|
42
|
+
@offer_count_by_redemption_method = Access::Aggregations.process_batch(@offer_count_by_redemption_method) if @offer_count_by_redemption_method
|
43
|
+
@offer_count_by_facet = Access::Aggregations.process_batch(@offer_count_by_facet) if @offer_count_by_facet
|
44
|
+
@custom_aggregation = Access::Aggregations.process_batch(@custom_aggregation) if @custom_aggregation
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
@@ -44,6 +49,8 @@ module Access
|
|
44
49
|
def process_data
|
45
50
|
(@stores = []; create_error) if @message
|
46
51
|
@stores = Access::Store.process_batch(@stores)
|
52
|
+
@offer_count_in_categories = Access::Aggregations.process_batch(@offer_count_in_categories) if @offer_count_in_categories
|
53
|
+
@custom_aggregation = Access::Aggregations.process_batch(@custom_aggregation) if @custom_aggregation
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
@@ -51,6 +58,7 @@ module Access
|
|
51
58
|
def process_data
|
52
59
|
(@locations = []; create_error) if @message
|
53
60
|
@locations = Access::Location.process_batch(@locations)
|
61
|
+
@custom_aggregation = Access::Aggregations.process_batch(@custom_aggregation) if @custom_aggregation
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -108,9 +116,16 @@ module Access
|
|
108
116
|
end
|
109
117
|
end
|
110
118
|
|
119
|
+
class MemberRegistrationResponse < Response
|
120
|
+
def process_data
|
121
|
+
@users = Access::Member.process_batch([@response])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
111
126
|
class MemberResponse < Response
|
112
127
|
def process_data
|
113
|
-
@
|
128
|
+
@users = Access::Member.process_batch(@users)
|
114
129
|
end
|
115
130
|
end
|
116
131
|
|
@@ -132,7 +147,7 @@ module Access
|
|
132
147
|
end
|
133
148
|
end
|
134
149
|
|
135
|
-
class
|
150
|
+
class CampaignResponse < Response
|
136
151
|
def process_data
|
137
152
|
@campaigns = Access::Campaign.process_batch(@campaigns)
|
138
153
|
end
|
@@ -144,4 +159,6 @@ module Access
|
|
144
159
|
end
|
145
160
|
end
|
146
161
|
|
162
|
+
|
163
|
+
|
147
164
|
end
|
data/lib/access/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: access
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Eggett
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-09-
|
13
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- bin/console
|
218
218
|
- bin/setup
|
219
219
|
- lib/access.rb
|
220
|
+
- lib/access/aggregations.rb
|
220
221
|
- lib/access/api.rb
|
221
222
|
- lib/access/autocomplete.rb
|
222
223
|
- lib/access/campaign.rb
|