oca-epak 1.1.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oca-epak/base_client.rb +3 -1
- data/lib/oca-epak/epak/client.rb +25 -38
- data/lib/oca-epak/oep/client.rb +3 -3
- data/lib/oca-epak/pickup_data.rb +3 -3
- data/lib/oca-epak/retiro.xml.erb +17 -0
- data/lib/oca-epak/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b770b600437c06428ca3857ee228823915a249b5
|
4
|
+
data.tar.gz: 9cca002c4d209ad4824026486fa959730e9181ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b707fa3733af3a184bce13abbb4802c3147c8b95d4a0f2bceba5faadacab82dc2484864b142f36b0c2022c817aa811308575bd8560242cc28d84e4710d58768
|
7
|
+
data.tar.gz: 897ee612dcb938f5adf5e97374647b855afbe9b669820da0252fd85135a2e27074baff33cf409811cb7bfb53ad7df87aa659a3a64fab3fef62d06cbba9aa966d
|
data/lib/oca-epak/base_client.rb
CHANGED
@@ -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
|
data/lib/oca-epak/epak/client.rb
CHANGED
@@ -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
|
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] :
|
65
|
-
# @option [String] :
|
66
|
-
#
|
67
|
-
# @option [
|
68
|
-
# @option [
|
69
|
-
# @option [
|
70
|
-
# @option [String] :
|
71
|
-
# @option [String] :
|
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
|
58
|
+
def get_shipping_rate(opts = {})
|
74
59
|
method = :tarifar_envio_corporativo
|
75
|
-
message = { "PesoTotal" => opts[:
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"
|
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
|
data/lib/oca-epak/oep/client.rb
CHANGED
@@ -9,9 +9,9 @@ module Oca
|
|
9
9
|
|
10
10
|
# Returns the HTML for a label
|
11
11
|
#
|
12
|
-
# @param opts
|
13
|
-
# @option
|
14
|
-
# @option
|
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
|
data/lib/oca-epak/pickup_data.rb
CHANGED
@@ -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>
|
data/lib/oca-epak/version.rb
CHANGED
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.
|
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:
|
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: []
|