oca-epak 1.0.1 → 1.1.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.rb +3 -1
- data/lib/oca-epak/base_client.rb +33 -0
- data/lib/oca-epak/{client.rb → epak/client.rb} +7 -32
- data/lib/oca-epak/errors/bad_request.rb +1 -1
- data/lib/oca-epak/errors/generic_error.rb +1 -1
- data/lib/oca-epak/oep/client.rb +25 -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: 63d16a3f53e35acefdb9f763c3d343ab7b56dc9b
|
4
|
+
data.tar.gz: 8e0ec175cc444b726e8594cde4eae24b954a0d53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f673dfb5d956e2bba94cb5967b655428c484d5e29302153e3896e954461c758ce7df8ff2a2b8d9fb2c826a8e8b3ef7cee8207cd1d97312264b26d737c44929e
|
7
|
+
data.tar.gz: e4feaf827f85af4f73412ae736c0d555fbb8096c8f77e1ada9d1d2de009c92db9f9ab8f71b0e1e434336638c4633aae333244fb3f11cb806a45a1f60fb427a4f
|
data/lib/oca-epak.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'savon'
|
2
2
|
require 'erb'
|
3
3
|
require 'ostruct'
|
4
|
-
require 'oca-epak/
|
4
|
+
require 'oca-epak/base_client'
|
5
|
+
require 'oca-epak/epak/client'
|
6
|
+
require 'oca-epak/oep/client'
|
5
7
|
require 'oca-epak/pickup_data'
|
6
8
|
require 'oca-epak/errors/generic_error'
|
7
9
|
require 'oca-epak/errors/bad_request'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Oca
|
2
|
+
class BaseClient
|
3
|
+
attr_reader :client
|
4
|
+
attr_accessor :username, :password
|
5
|
+
|
6
|
+
BASE_WSDL_URL = 'http://webservice.oca.com.ar'.freeze
|
7
|
+
|
8
|
+
def initialize(username, password)
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def parse_result(response, method)
|
16
|
+
method_response = "#{method}_response".to_sym
|
17
|
+
method_result = "#{method}_result".to_sym
|
18
|
+
if body = response.body[method_response]
|
19
|
+
body[method_result]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse_results_table(response, method)
|
24
|
+
if result = parse_result(response, method)
|
25
|
+
if result[:diffgram][:new_data_set]
|
26
|
+
result[:diffgram][:new_data_set][:table]
|
27
|
+
else
|
28
|
+
raise Oca::Errors::BadRequest.new("Oca WS responded with:\n#{response.body}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
module Oca
|
2
2
|
module Epak
|
3
|
-
class Client
|
4
|
-
attr_reader :client
|
5
|
-
attr_accessor :username, :password
|
6
|
-
|
7
|
-
WSDL = 'http://webservice.oca.com.ar/epak_tracking/Oep_TrackEPak.asmx?wsdl'.freeze
|
8
|
-
|
3
|
+
class Client < BaseClient
|
9
4
|
def initialize(username, password)
|
10
|
-
|
11
|
-
|
12
|
-
@
|
5
|
+
super
|
6
|
+
wsdl_url = "#{BASE_WSDL_URL}/epak_tracking/Oep_TrackEPak.asmx?wsdl"
|
7
|
+
@client = Savon.client(wsdl: wsdl_url)
|
13
8
|
end
|
14
9
|
|
15
10
|
# Checks if the user has input valid credentials
|
@@ -33,7 +28,7 @@ module Oca
|
|
33
28
|
qty: "1", total: "123", cuit: cuit, op: op }
|
34
29
|
get_shipping_rates(opts)
|
35
30
|
true
|
36
|
-
rescue Oca::
|
31
|
+
rescue Oca::Errors::GenericError => e
|
37
32
|
false
|
38
33
|
end
|
39
34
|
end
|
@@ -45,7 +40,7 @@ module Oca
|
|
45
40
|
# @param [Hash] opts
|
46
41
|
# @option [Oca::Epak::PickupData] :pickup_data Pickup Data object
|
47
42
|
# @option [Boolean] :confirm_pickup Confirm Pickup? Defaults to false
|
48
|
-
# @option [Integer] :days_to_pickup Days OCA should wait before pickup, default: 1
|
43
|
+
# @option [Integer] :days_to_pickup Days OCA should wait before pickup, default: 1
|
49
44
|
# @option [Integer] :pickup_range Range to be used when picking it up, default: 1
|
50
45
|
# @return [Hash, nil]
|
51
46
|
def create_pickup_order(opts = {})
|
@@ -60,7 +55,7 @@ module Oca
|
|
60
55
|
"DiasHastaRetiro" => days_to_pickup,
|
61
56
|
"idFranjaHoraria" => pickup_range }
|
62
57
|
response = client.call(:ingreso_or, message: message)
|
63
|
-
|
58
|
+
parse_result(response, :ingreso_or)
|
64
59
|
end
|
65
60
|
|
66
61
|
# Get rates and delivery estimate for a shipment
|
@@ -130,26 +125,6 @@ module Oca
|
|
130
125
|
body[:get_provincias_result][:provincias][:provincia]
|
131
126
|
end
|
132
127
|
end
|
133
|
-
|
134
|
-
private
|
135
|
-
|
136
|
-
def parse_result(response, method)
|
137
|
-
method_response = "#{method}_response".to_sym
|
138
|
-
method_result = "#{method}_result".to_sym
|
139
|
-
if body = response.body[method_response]
|
140
|
-
body[method_result]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def parse_results_table(response, method)
|
145
|
-
if result = parse_result(response, method)
|
146
|
-
if result[:diffgram][:new_data_set]
|
147
|
-
result[:diffgram][:new_data_set][:table]
|
148
|
-
else
|
149
|
-
raise Oca::Epak::BadRequest.new("Oca WS responded with:\n#{response.body}")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
128
|
end
|
154
129
|
end
|
155
130
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Oca
|
2
|
+
module Oep
|
3
|
+
class Client < BaseClient
|
4
|
+
def initialize(username, password)
|
5
|
+
super
|
6
|
+
wsdl_url = "#{BASE_WSDL_URL}/oep_tracking/Oep_Track.asmx?wsdl"
|
7
|
+
@client = Savon.client(wsdl: wsdl_url)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns the HTML for a label
|
11
|
+
#
|
12
|
+
# @param opts
|
13
|
+
# @option id_orden_retiro [Integer]
|
14
|
+
# @option nro_envio [String]
|
15
|
+
# @return [String] HTML
|
16
|
+
def get_html_de_etiquetas_por_orden_or_numero_envio(opts = {})
|
17
|
+
method = :get_html_de_etiquetas_por_orden_or_numero_envio
|
18
|
+
opts = { "idOrdenRetiro" => opts[:id_orden_retiro],
|
19
|
+
"nroEnvio" => opts[:nro_envio] }
|
20
|
+
response = client.call(method, message: opts)
|
21
|
+
parse_result(response, method)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
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.0
|
4
|
+
version: 1.1.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-
|
12
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -104,9 +104,11 @@ extensions: []
|
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
106
|
- lib/oca-epak.rb
|
107
|
-
- lib/oca-epak/
|
107
|
+
- lib/oca-epak/base_client.rb
|
108
|
+
- lib/oca-epak/epak/client.rb
|
108
109
|
- lib/oca-epak/errors/bad_request.rb
|
109
110
|
- lib/oca-epak/errors/generic_error.rb
|
111
|
+
- lib/oca-epak/oep/client.rb
|
110
112
|
- lib/oca-epak/pickup_data.rb
|
111
113
|
- lib/oca-epak/version.rb
|
112
114
|
homepage: https://github.com/ombulabs/oca-epak
|