tray-checkout 0.4.2 → 0.4.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTZhMjQ2ZTYyZmI5OTYwZjZmMTRlNzhmMzU5MjZiMzkwNzE4OGQ5NQ==
4
+ OGM3MDBhZDNlODkzYWE5MGEwYjI0YjFlMzJlMjhkNGJiNzE2Y2Q3Yg==
5
5
  data.tar.gz: !binary |-
6
- MjY4MmQ5Y2U1ZmI4NzhiNjBmYjg4NDg4MDBlMmIyM2U2YzFiMmUyMg==
6
+ YzBkZDI4MjZiYjQ2MmMzM2IzNjRmOTFkMTY3ZmQ3NmUxY2M4MzVkNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTk1YzFlMDkyYmZjODVkNTExZGQxMGI3YTg5ZTA3ZmI5ZDdiNTFhNzY3MmNh
10
- ZjgzNzFiYzRmODJiODY4ZTBiZTU1NWQ3ZWEzMzhjN2U2ZGM1NDcwZTQ1Y2I4
11
- NTFkMjBlMGVlZjlhNGE0NTc2NTNjMjQzODAwZWU0YmI5NjFiNjE=
9
+ ZmEzOTcwNWE3OTFkNTdkMDRiOTBlNDlhZDZhMjcyZjQ1NzBiYjJlMjg1Yjhk
10
+ MTdlYzVjNWI2NDU2YWMxODBjM2M0ZDU1NDI1Y2I4ZDBhMzIyY2IzZGY4ZTBl
11
+ ZDU0YWRhMjJiNDU1N2ZmYWNmYTlhMTg2ZTAwOTZjZTBkNGY5ZDM=
12
12
  data.tar.gz: !binary |-
13
- NTIwMDhlZWE1OWVjZTU5YjQ3N2ZjMjMzMTRhNzBmYmY0MWFmMmM4MTdjZDlj
14
- YjQyZDRkYzY2YzFjNzMxNDY1YWZhZjA1MTJlMDE5OTBhODU0YmJlYTVhZjli
15
- OGVkYzUzNWZhZDkyNWY2N2Y1OTFmODMxMDFjODk5YjcwYjllOGI=
13
+ NmMzOTUzNGYyNmM4NDI0MGU4OTI3YjFiYTcyOGY0NDUwYzgxYmY0YjBlNjEz
14
+ NmQxODcxMGY1NmYyNjYwZjA3MGQ3ZTBiZTU5ZTgzODc4NGEwMGJlY2MzMDUx
15
+ NDliOTNiYThlYmJiM2MzNDZhZTFkMGNmZWE0YTg0MGE4MTA0MGE=
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == Version 0.4.3
2
+ - "url_img" parameter is in "product", not in "transaction".
3
+
1
4
  == Version 0.4.2
2
5
  - Avoid errors in TrayCheckout API when "url_img" parameter does not have a value.
3
6
 
@@ -8,7 +8,6 @@ module Tray
8
8
 
9
9
  def parse
10
10
  token_account! @params
11
- transaction_map! @params
12
11
  customer_map! @params[:customer]
13
12
  payment_map! @params[:payment]
14
13
  products_map! @params
@@ -21,14 +20,6 @@ module Tray
21
20
  params[:token_account] = Tray::Checkout.token_account if params[:token_account].nil?
22
21
  end
23
22
 
24
- def transaction_map!(params)
25
- return unless params[:transaction]
26
-
27
- if params[:transaction][:url_img].to_s.empty?
28
- params[:transaction].delete(:url_img)
29
- end
30
- end
31
-
32
23
  def customer_map!(customer)
33
24
  return unless customer
34
25
  customer[:birth_date] = customer[:birth_date].strftime("%d/%m/%Y") if customer[:birth_date] && customer[:birth_date].is_a?(Date)
@@ -63,7 +54,12 @@ module Tray
63
54
 
64
55
  def products_map!(params)
65
56
  return unless params[:transaction]
57
+
66
58
  params[:transaction_product] = params[:transaction].delete(:products)
59
+
60
+ params[:transaction_product].each do |product|
61
+ product.delete(:url_img) if product[:url_img].to_s.empty?
62
+ end
67
63
  end
68
64
  end
69
65
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  module Tray
3
3
  module Checkout
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
6
6
  end
7
7
 
@@ -41,17 +41,18 @@ describe Tray::Checkout::ParamsParser do
41
41
  shipping_type: "Sedex",
42
42
  shipping_price: 13.94,
43
43
  url_notification: "http://prodis.blog.br/tray_notification",
44
- url_img: "http://prodis.net.br/images/prodis_150.gif",
45
44
  products: [
46
45
  { code: "LOGO-8278",
47
46
  quantity: 2,
48
47
  price_unit: 100.99,
49
- description: "Logo Prodis"
48
+ description: "Logo Prodis",
49
+ url_img: "http://prodis.net.br/images/prodis_150.gif"
50
50
  },
51
51
  { code: "877",
52
52
  quantity: 1,
53
53
  price_unit: 10.00,
54
- description: "Outro produto"
54
+ description: "Outro produto",
55
+ url_img: nil
55
56
  }
56
57
  ]
57
58
  },
@@ -73,19 +74,6 @@ describe Tray::Checkout::ParamsParser do
73
74
  let(:response_params) { parser.parse }
74
75
 
75
76
  describe "#parse" do
76
- context "when transaction has image URL" do
77
- it "keeps image URL parameter" do
78
- response_params[:transaction][:url_img].should == params[:transaction][:url_img]
79
- end
80
- end
81
-
82
- context "when image URL is nil" do
83
- it "removes image URL parameter" do
84
- params[:transaction][:url_img] = nil
85
- response_params[:transaction].has_key?(:url_img).should eq false
86
- end
87
- end
88
-
89
77
  it "sets customer gender expect API value" do
90
78
  response_params[:customer][:gender].should == "M"
91
79
  end
@@ -138,6 +126,18 @@ describe Tray::Checkout::ParamsParser do
138
126
  response_params[:transaction_product][1][:description].should == "Outro produto"
139
127
  end
140
128
 
129
+ context "when product has image" do
130
+ it "keeps image URL parameter" do
131
+ response_params[:transaction_product][0][:url_img].should == "http://prodis.net.br/images/prodis_150.gif"
132
+ end
133
+ end
134
+
135
+ context "when image URL parameter is nil" do
136
+ it "removes image URL parameter" do
137
+ response_params[:transaction_product][1].has_key?(:url_img).should eq false
138
+ end
139
+ end
140
+
141
141
  it "keeps token account supplied in params" do
142
142
  response_params[:token_account].should == params[:token_account]
143
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tray-checkout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Prodis a.k.a. Fernando Hamasaki