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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c5bf1a0a2b23e64846e9e907d376ec5e582d832db7261791e357b4334bc07b0
4
- data.tar.gz: 0dbc1f82719718abfdc62fa707a6f1c81192460bb344aca38b1426fe2a51fd40
3
+ metadata.gz: 5a897146caa3be62db87d4e0778715429b43708128d7e1c0eebc52fe6494c1c2
4
+ data.tar.gz: 21658ffbab44cf822a408d9d3565aea531621013ab8fce20274377fb37918a09
5
5
  SHA512:
6
- metadata.gz: 9b317249642aec0e9b0e82bff09a6839cf1372476fde1006296c7a9013c5296fbebb84acaf59b8698f33a7d5c9a08ea3f4fba0f0cb7090745c6ad0d295398d73
7
- data.tar.gz: a75ed8038f593cfc63b428d5a6577a63200a06c016d5ca8627818c4286a34e4b568c586cd9a39a91339948b83e05a6c72c245a7ebfaaa2809d713ee92e5b7a57
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(id, token, attributes)
7
- respone = RestClient::Request.execute(
8
- :method => :get,
9
- params: { id: id },
10
- attributes: attributes,
11
- token: token,
12
- :url => url,
13
- :timeout => 1,
14
- :open_timeout => 1,
15
- content_type: :json
16
- )
17
- if response.code == 200
18
- JSON.parse(response.body)
19
- else
20
- raise "No aplica"
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
- # 'https://couponsv2-promotions.azurewebsites.net/promotions'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promotion_evaluation_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASP Coupons