promotion_evaluation_service 1.0.3 → 1.0.4
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/lib/promotion_evaluation_service.rb +17 -18
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a897146caa3be62db87d4e0778715429b43708128d7e1c0eebc52fe6494c1c2
|
|
4
|
+
data.tar.gz: 21658ffbab44cf822a408d9d3565aea531621013ab8fce20274377fb37918a09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fd0208a289aaa20abf04d989dbf22af9991495d62c30d254074c190e9eccf629320f50cf2c83878b0c797748dffe9604f5e20a70d163d9a6cf7a98767bae953
|
|
7
|
+
data.tar.gz: 5b3db6e57112dedcb5aaa61084b362cdd2d0647eb48e71003545bcadd894c548deb36d79f1e23e4bff18b6502a45cbae9449f85ec04930379f8ab79201f013be
|
|
@@ -3,29 +3,28 @@ require 'json'
|
|
|
3
3
|
|
|
4
4
|
class PromotionEvaluationService
|
|
5
5
|
|
|
6
|
-
def evaluate(
|
|
7
|
-
|
|
8
|
-
:
|
|
9
|
-
|
|
10
|
-
attributes: attributes,
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
def evaluate(promotion_id, token, attributes, demographic_data)
|
|
7
|
+
response = RestClient::Request.new({
|
|
8
|
+
method: :post,
|
|
9
|
+
url: url(promotion_id),
|
|
10
|
+
payload: { attributes: attributes, demographic_data: demographic_data, token: token },
|
|
11
|
+
headers: { content_type: :json },
|
|
12
|
+
timeout: 1,
|
|
13
|
+
open_timeout: 1
|
|
14
|
+
}).execute do |response, request, result|
|
|
15
|
+
case response.code
|
|
16
|
+
when 200
|
|
17
|
+
puts JSON.parse(response.body)
|
|
18
|
+
else
|
|
19
|
+
puts "No aplica"
|
|
20
|
+
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
|
-
def url
|
|
27
|
-
|
|
28
|
-
ENV['PROMOTIONS_SERVICE_URL']
|
|
26
|
+
def url(promotion_id)
|
|
27
|
+
"https://couponsv2-promotions.azurewebsites.net/promotions" + promotion_id + "/evaluate"
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
end
|