oca-epak 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82bf4c58e32451b35b9b97837026e0f97d19be74
4
- data.tar.gz: 13bc295555dbe8c89ff3cb266f9b61e37ba25b01
3
+ metadata.gz: 6a39d87e990681613b5f0fc131eda9e9eb65b478
4
+ data.tar.gz: 30e61cf43e374e8a63fc98471bd717fbfb104725
5
5
  SHA512:
6
- metadata.gz: 6c65fc84cab5bce03049b3c8ca7cb548e4d0d7af61a9ea81750e341f569e326ce9fa98b68032a0fac9f627bede7345233d0a88a9d3195fe6271e7c646889b420
7
- data.tar.gz: 053e67d987b15736723eb8ce7a11f4211a75973915a6e05cf27c0e8e3eb988c33e309d4d1ced96efe34acc630e3cd6056ff66168013c62a3ed614b2b65f87f2b
6
+ metadata.gz: bf90553a213acd64ac611799d0d384a78683d29629d602eb1fc3f05abf7a01d1752d44756d63a1e4117941714ac6a05e936830e62d5415639730d58f3ce3f121
7
+ data.tar.gz: 1753a1f606481eaa1cd527c086000b53882330633f44aa7aaa17e39921b8e7f715b29fa3bad0f41e1ccacf774e968ef39bc7fc078d423d2184c2a4f94070d149
@@ -5,6 +5,7 @@ module Oca
5
5
  USER_STRING = "usr".freeze
6
6
  PASSWORD_STRING = "psw".freeze
7
7
  WSDL_URL = "#{BASE_WSDL_URL}/epak_tracking/Oep_TrackEPak.asmx?wsdl".freeze
8
+ CUIT_PATTERN = /[0-9]{2}-[0-9]{8}-[0-9]/
8
9
 
9
10
  def initialize(username, password)
10
11
  super
@@ -61,6 +62,8 @@ module Oca
61
62
  # @option opts [String] :operation_code Operation Type
62
63
  # @return [Hash, nil] Contains Total Price, Delivery Estimate
63
64
  def get_shipping_rate(opts = {})
65
+ cuit_number = normalize_cuit(opts[:cuit])
66
+
64
67
  method = :tarifar_envio_corporativo
65
68
  message = { "PesoTotal" => opts[:total_weight],
66
69
  "VolumenTotal" => opts[:total_volume],
@@ -68,7 +71,7 @@ module Oca
68
71
  "CodigoPostalDestino" => opts[:destination_zip_code],
69
72
  "ValorDeclarado" => opts[:declared_value],
70
73
  "CantidadPaquetes" => opts[:package_quantity],
71
- "Cuit" => opts[:cuit],
74
+ "Cuit" => cuit_number,
72
75
  "Operativa" => opts[:operation_code] }
73
76
  response = client.call(method, message: message)
74
77
  parse_results_table(response, method).first
@@ -110,8 +113,10 @@ module Oca
110
113
  # @param [String] "To date" in DD-MM-YYYY format
111
114
  # @return [Array, nil] Contains an array of hashes with NroProducto and NumeroEnvio
112
115
  def list_shipments(cuit, from_date, to_date)
116
+ cuit_number = normalize_cuit(cuit)
117
+
113
118
  method = :list_envios
114
- opts = { "CUIT" => cuit, "FechaDesde" => from_date,
119
+ opts = { "CUIT" => cuit_number, "FechaDesde" => from_date,
115
120
  "FechaHasta" => to_date }
116
121
  response = client.call(method, message: opts)
117
122
  parse_results_table(response, method)
@@ -135,11 +140,12 @@ module Oca
135
140
  # @return [Hash, nil] Contains the history of object's movement.
136
141
  def tracking_object(opts = {})
137
142
  message = {
138
- "Cuit" => opts[:cuit],
143
+ "Cuit" => normalize_cuit(opts[:cuit]),
139
144
  "Pieza" => opts[:pieza]
140
145
  }
141
146
 
142
147
  response = client.call(:tracking_pieza, message: message)
148
+
143
149
  parse_result(response, :tracking_pieza)
144
150
  end
145
151
 
@@ -169,7 +175,16 @@ module Oca
169
175
  method = :get_centros_imposicion_con_servicios_by_cp
170
176
  response = client.call(method, message: message)
171
177
  parse_result(response, method)
172
- end
178
+ end
179
+
180
+ private
181
+ def normalize_cuit(cuit)
182
+ if (cuit =~ CUIT_PATTERN).nil?
183
+ "%s-%s-%s" %[cuit[0..1], cuit[2..9], cuit[10]]
184
+ else
185
+ cuit
186
+ end
187
+ end
173
188
  end
174
189
  end
175
190
  end
@@ -1,5 +1,5 @@
1
1
  module Oca
2
2
  module Epak
3
- VERSION = '1.8.0'
3
+ VERSION = '1.9.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oca-epak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauro Otonelli
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-04 00:00:00.000000000 Z
12
+ date: 2018-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.4.8
150
+ rubygems_version: 2.6.14
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: OCA E-Pak