oca-epak 1.1.0 → 1.5.0

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
  SHA1:
3
- metadata.gz: 63d16a3f53e35acefdb9f763c3d343ab7b56dc9b
4
- data.tar.gz: 8e0ec175cc444b726e8594cde4eae24b954a0d53
3
+ metadata.gz: b770b600437c06428ca3857ee228823915a249b5
4
+ data.tar.gz: 9cca002c4d209ad4824026486fa959730e9181ae
5
5
  SHA512:
6
- metadata.gz: 8f673dfb5d956e2bba94cb5967b655428c484d5e29302153e3896e954461c758ce7df8ff2a2b8d9fb2c826a8e8b3ef7cee8207cd1d97312264b26d737c44929e
7
- data.tar.gz: e4feaf827f85af4f73412ae736c0d555fbb8096c8f77e1ada9d1d2de009c92db9f9ab8f71b0e1e434336638c4633aae333244fb3f11cb806a45a1f60fb427a4f
6
+ metadata.gz: 2b707fa3733af3a184bce13abbb4802c3147c8b95d4a0f2bceba5faadacab82dc2484864b142f36b0c2022c817aa811308575bd8560242cc28d84e4710d58768
7
+ data.tar.gz: 897ee612dcb938f5adf5e97374647b855afbe9b669820da0252fd85135a2e27074baff33cf409811cb7bfb53ad7df87aa659a3a64fab3fef62d06cbba9aa966d
@@ -20,10 +20,12 @@ module Oca
20
20
  end
21
21
  end
22
22
 
23
+ # @return [Array, nil]
23
24
  def parse_results_table(response, method)
24
25
  if result = parse_result(response, method)
25
26
  if result[:diffgram][:new_data_set]
26
- result[:diffgram][:new_data_set][:table]
27
+ table = result[:diffgram][:new_data_set][:table]
28
+ table.is_a?(Hash) ? [table] : table
27
29
  else
28
30
  raise Oca::Errors::BadRequest.new("Oca WS responded with:\n#{response.body}")
29
31
  end
@@ -14,34 +14,18 @@ module Oca
14
14
  method = :get_epack_user
15
15
  opts = { "usr" => username, "psw" => password }
16
16
  response = client.call(method, message: opts)
17
- parse_results_table(response, method)[:existe] == "1"
18
- end
19
-
20
- # Checks whether the operation is valid
21
- #
22
- # @param [String] Client's CUIT
23
- # @param [String] Operation Type
24
- # @return [Boolean]
25
- def check_operation(cuit, op)
26
- begin
27
- opts = { wt: "50", vol: "0.027", origin: "1414", destination: "5403",
28
- qty: "1", total: "123", cuit: cuit, op: op }
29
- get_shipping_rates(opts)
30
- true
31
- rescue Oca::Errors::GenericError => e
32
- false
33
- end
17
+ parse_results_table(response, method).first[:existe] == "1"
34
18
  end
35
19
 
36
20
  # Creates a Pickup Order, which lets OCA know you want to make a delivery.
37
21
  #
38
- # @see [http://www.ombushop.com/oca/documentation.pdf] #TODO put it there
22
+ # @see https://github.com/ombulabs/oca-epak/blob/master/doc/OCAWebServices.pdf
39
23
  #
40
24
  # @param [Hash] opts
41
- # @option [Oca::Epak::PickupData] :pickup_data Pickup Data object
42
- # @option [Boolean] :confirm_pickup Confirm Pickup? Defaults to false
43
- # @option [Integer] :days_to_pickup Days OCA should wait before pickup, default: 1
44
- # @option [Integer] :pickup_range Range to be used when picking it up, default: 1
25
+ # @option opts [Oca::Epak::PickupData] :pickup_data Pickup Data object
26
+ # @option opts [Boolean] :confirm_pickup Confirm Pickup? Defaults to false
27
+ # @option opts [Integer] :days_to_pickup Days OCA should wait before pickup, default: 1
28
+ # @option opts [Integer] :pickup_range Range to be used when picking it up, default: 1
45
29
  # @return [Hash, nil]
46
30
  def create_pickup_order(opts = {})
47
31
  confirm_pickup = opts.fetch(:confirm_pickup, false)
@@ -61,25 +45,28 @@ module Oca
61
45
  # Get rates and delivery estimate for a shipment
62
46
  #
63
47
  # @param [Hash] opts
64
- # @option [String] :wt Total Weight e.g: 20
65
- # @option [String] :vol Total Volume e.g: 0.0015 (0.1mts * 0.15mts * 0.1mts)
66
- # @option [Integer] :origin Origin ZIP Code
67
- # @option [Integer] :destination Destination ZIP Code
68
- # @option [Integer] :qty Quantity of Packages
69
- # @option [Integer] :total Declared Value
70
- # @option [String] :cuit Client's CUIT e.g: 30-99999999-7
71
- # @option [String] :op Operation Type
48
+ # @option opts [String] :total_weight Total Weight e.g: 20
49
+ # @option opts [String] :total_volume Total Volume e.g: 0.0015
50
+ # (0.1mts * 0.15mts * 0.1mts)
51
+ # @option opts [String] :origin_zip_code Origin ZIP Code
52
+ # @option opts [String] :destination_zip_code Destination ZIP Code
53
+ # @option opts [String] :declared_value Declared Value
54
+ # @option opts [String] :package_quantity Quantity of Packages
55
+ # @option opts [String] :cuit Client's CUIT e.g: 30-99999999-7
56
+ # @option opts [String] :operation_code Operation Type
72
57
  # @return [Hash, nil] Contains Total Price, Delivery Estimate
73
- def get_shipping_rates(opts = {})
58
+ def get_shipping_rate(opts = {})
74
59
  method = :tarifar_envio_corporativo
75
- message = { "PesoTotal" => opts[:wt], "VolumenTotal" => opts[:vol],
76
- "CodigoPostalOrigen" => opts[:origin],
77
- "CodigoPostalDestino" => opts[:destination],
78
- "ValorDeclarado" => opts[:total],
79
- "CantidadPaquetes" => opts[:qty], "Cuit" => opts[:cuit],
80
- "Operativa" => opts[:op] }
60
+ message = { "PesoTotal" => opts[:total_weight],
61
+ "VolumenTotal" => opts[:total_volume],
62
+ "CodigoPostalOrigen" => opts[:origin_zip_code],
63
+ "CodigoPostalDestino" => opts[:destination_zip_code],
64
+ "ValorDeclarado" => opts[:declared_value],
65
+ "CantidadPaquetes" => opts[:package_quantity],
66
+ "Cuit" => opts[:cuit],
67
+ "Operativa" => opts[:operation_code] }
81
68
  response = client.call(method, message: message)
82
- parse_results_table(response, method)
69
+ parse_results_table(response, method).first
83
70
  end
84
71
 
85
72
  # Returns all existing Taxation Centers
@@ -9,9 +9,9 @@ module Oca
9
9
 
10
10
  # Returns the HTML for a label
11
11
  #
12
- # @param opts
13
- # @option id_orden_retiro [Integer]
14
- # @option nro_envio [String]
12
+ # @param [Hash] opts
13
+ # @option opts [Integer] :id_orden_retiro
14
+ # @option opts [String] :nro_envio
15
15
  # @return [String] HTML
16
16
  def get_html_de_etiquetas_por_orden_or_numero_envio(opts = {})
17
17
  method = :get_html_de_etiquetas_por_orden_or_numero_envio
@@ -6,9 +6,9 @@ module Oca
6
6
  # Creates a Pickup Data object for creating a pickup order in OCA.
7
7
  #
8
8
  # @param [Hash] opts
9
- # @option [String] :account_number Account Number (SAP)
10
- # @option [Hash] :pickup Pickup Hash
11
- # @option [Array<Hash>] :shipments Shipments Hash
9
+ # @option opts [String] :account_number Account Number (SAP)
10
+ # @option opts [Hash] :pickup Pickup Hash
11
+ # @option opts [Array<Hash>] :shipments Shipments Hash
12
12
  def initialize(opts = {})
13
13
  self.account_number = opts[:account_number]
14
14
  self.pickup = opts[:pickup]
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
2
+ <ROWS>
3
+ <cabecera ver="1.0" nrocuenta="<%= account_number %>" />
4
+ <retiro calle="<%= pickup['calle'] %>" nro="<%= pickup['numero'] %>" piso="<%= pickup['piso'] %>" depto="<%= pickup['departamento'] %>" cp="<%= pickup['cp'] %>" localidad="<%= pickup['localidad'] %>" provincia="<%= pickup['provincia'] %>" contacto="<%= pickup['solicitante'] %>" email="<%= pickup['email'] %>" solicitante="<%= pickup['solicitante'] %>" observaciones="<%= pickup['observaciones'] %>" centrocosto="<% if pickup['centro_de_costo'] %><%= pickup['centro_de_costo'] %><% else %>0<% end %>" />
5
+ <envios>
6
+ <%- shipments.each do |shipment| -%>
7
+ <envio idoperativa="<%= shipment['id_operativa'] %>" nroremito="<%= shipment['numero_remito'] %>">
8
+ <destinatario apellido="<%= shipment['destinatario']['apellido'] %>" nombre="<%= shipment['destinatario']['nombre'] %>" calle="<%= shipment['destinatario']['calle'] %>" nro="<%= shipment['destinatario']['numero'] %>" piso="<%= shipment['destinatario']['piso'] %>" depto="<%= shipment['destinatario']['departamento'] %>" cp="<%= shipment['destinatario']['cp'] %>" localidad="<%= shipment['destinatario']['localidad'] %>" provincia="<%= shipment['destinatario']['provincia'] %>" telefono="<%= shipment['destinatario']['telefono'] %>" email="<%= shipment['destinatario']['email'] %>" idci="<% if shipment['destinatario']['centro_de_costo'] %><%= shipment['destinatario']['centro_de_costo'] %><% else %>0<% end %>" celular="<%= shipment['destinatario']['celular'] %>"/>
9
+ <paquetes>
10
+ <%- shipment['paquetes'].each do |package|-%>
11
+ <paquete alto="<%= package['alto'] %>" ancho="<%= package['ancho'] %>" largo="<%= package['largo'] %>" peso="<%= package['peso'] %>" valor="<%= package['valor_declarado'] %>" cant="<%= package['cantidad'] %>"/>
12
+ <%- end -%>
13
+ </paquetes>
14
+ </envio>
15
+ <%- end -%>
16
+ </envios>
17
+ </ROWS>
@@ -1,5 +1,5 @@
1
1
  module Oca
2
2
  module Epak
3
- VERSION = '1.1.0'
3
+ VERSION = '1.5.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.1.0
4
+ version: 1.5.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: 2015-11-19 00:00:00.000000000 Z
12
+ date: 2016-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -110,9 +110,11 @@ files:
110
110
  - lib/oca-epak/errors/generic_error.rb
111
111
  - lib/oca-epak/oep/client.rb
112
112
  - lib/oca-epak/pickup_data.rb
113
+ - lib/oca-epak/retiro.xml.erb
113
114
  - lib/oca-epak/version.rb
114
115
  homepage: https://github.com/ombulabs/oca-epak
115
- licenses: []
116
+ licenses:
117
+ - MIT
116
118
  metadata: {}
117
119
  post_install_message:
118
120
  rdoc_options: []