ruby-anmat 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 5ecadfe75e31c96ceae9db7f96c2011120589aec4a74f1ed5a6cfaf7b21071d3
4
- data.tar.gz: cacd4296ccc4639baae2135301bdf6cff36fe27bfb680171248e401c545644eb
3
+ metadata.gz: ef4a03aeda10bcdfda47833f83abc00d8c01602a91b71e7bab5535e7851e696c
4
+ data.tar.gz: 21aa9cda76d20f7456b7816fe6e7e11e766e4d5588ed467682f1d189ff988154
5
5
  SHA512:
6
- metadata.gz: cd4d3df44df5c2b1fc1896671e05691a13665d5349a860b5fda363833380195c2a2831a85d3a0bfac08581263267db7f215ef4de4f920c95ad86043bdf0fefd3
7
- data.tar.gz: 84f63f9462fe26e249a3d4849286e30fbc5cf8a04c1ad1878bf1cf238a3fcd02c6d585e98097926351efea02d3c8597e35d6049b8f6bc1661f9625d4e9638891
6
+ metadata.gz: 3801a524148e3b770ae27d1d00394262380342aafe4db857f9d26c35fd2bcdabd702a8fc56f9745c0c38637e6da758060e09199cb2907b00bc57552c06f2fd60
7
+ data.tar.gz: 4dc790619717af0752c595f74dcc77efeb575f1754716c0c1a2eb4e8a6fe555f65b9ce729edaca5639487a136f9da42a24a2f6d0ebc0dbc48453a82b5f8074d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-anmat (0.1.0)
4
+ ruby-anmat (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,66 +2,135 @@ module Ruby
2
2
  module Anmat
3
3
  class Traceability
4
4
 
5
- def initialize(args={}, environment = :test)
5
+ def initialize(args= {}, environment = :test)
6
6
  @environment = environment
7
- @f_evento = args["f_evento"] || "20/01/2013"
8
- @h_evento = args["h_evento"] || "23:59"
9
- @gln_origen = args["gln_origen"] || "glnws"
10
- @gln_destino = args["gln_destino"] || "GLN-1"
11
- @n_remito = args["n_remito"] || "1"
12
- @n_factura = args["n_factura"] || "1"
13
- @vencimiento = args["vencimiento"] || "01/05/2011"
14
- @gtin = args["gtin"] || "GTIN1"
15
- @lote = args["lote"] || "1"
16
- @numero_serial = args["numero_serial"] || rand(1300..99999999).to_s
17
- @id_evento = args["id_evento"] || "133"
18
- @n_postal = args["n_postal"] || "1416"
19
- @telefono = args["telefono"] || "45880712"
7
+ @usuartio_laboratorio_2 = args[:usuartio_laboratorio_2] || '9999999999918'
8
+ @pass_laboratorio_2 = args[:pass_laboratorio_2] || 'Pami1111'
9
+ @gln_laboratorio_2 = args[:gln_laboratorio_2] || '9999999999918'
20
10
 
21
- @user = 'pruebasws'
22
- @pass = 'pruebasws'
11
+ @usuario_laboratorio_1 = args[:usuario_laboratorio_1] || 'pruebasws'
12
+ @pass_laboratorio_1 = args[:pass_laboratorio_1] || 'pruebasws'
13
+ @gln_laboratorio_1 = args[:gln_laboratorio_1] || 'glnws'
14
+
15
+ @gln_drogueria = args[:gln_drogueria] || "9999999999925";
23
16
  end
24
17
 
25
18
  def set_client
26
19
  @client = Savon.client(
27
20
  wsdl: Anmat::URLS[@environment][:wsdl],
21
+ endpoint: 'https://servicios.pami.org.ar/trazamed.WebService',
22
+ wsse_auth: ['testwservice', 'testwservicepsw'],
28
23
  namespaces: Anmat::NAMESPACES,
24
+ namespace_identifier: :ns1,
25
+ log: true,
29
26
  log_level: :debug,
30
- ssl_verify_mode: :none,
31
- read_timeout: 90,
32
- open_timeout: 90,
33
- headers: { "Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive" }
27
+ pretty_print_xml: true,
28
+ headers: { "Accept-Encoding" => "gzip, deflate", "Connection" => "close" }
34
29
  )
35
30
  end
36
31
 
37
- def send_medicamentos
38
- set_client
39
- body = set_body
40
-
41
- response = @client.call(:send_medicamentos, message: body)
32
+ def responder(response)
42
33
  pp response
34
+ errores = ""
35
+ id_transaccion = ""
36
+ resultado = ""
37
+ transacciones = []
38
+ if response[:return]
39
+ resultado = response[:return][:resultado]
40
+ id_transaccion = response[:return][:codigo_transaccion] || response[:return][:id_transac_asociada]
41
+ transacciones = response[:return][:list]
42
+ if response[:return][:errores]
43
+ response[:return][:errores].each do |k,v|
44
+ if v.is_a?(Array)
45
+ errores << "Código: " + v['_c_error'] + ". - Descripción: " + v['_d_error'] +".\n"
46
+ else
47
+ errores << v + "-"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ return {resultado: resultado, id_transaccion: id_transaccion, transacciones: transacciones, errores: errores}
43
53
  end
44
54
 
45
- def set_body
46
- {
55
+ def send_medicamentos(args={})
56
+ set_client
57
+ random_serial = rand(1300..99999999)
58
+ body = {
47
59
  "arg0" => {
48
- "f_evento" => @f_evento,
49
- "h_evento" => @h_evento,
50
- "gln_origen" => @gln_origen,
51
- "gln_destino" => @gln_destino,
52
- "n_remito" => @n_remito,
53
- "n_factura" => @n_factura,
54
- "vencimiento" => @vencimiento,
55
- "gtin" => @gtin,
56
- "lote" => @lote,
57
- "numero_serial" => @numero_serial,
58
- "id_evento" => @id_evento,
59
- "n_postal" => @n_postal,
60
- "telefono" => @telefono,
60
+ "f_evento" => args[:f_evento] || "20/01/2013" ,
61
+ "h_evento" => args[:h_evento] || "13:15",
62
+ "gln_origen" => args[:gln_origen] || @gln_laboratorio_2,
63
+ "gln_destino" => args[:gln_destino] || @gln_laboratorio_1,
64
+ "n_remito" => args[:n_remito] || "R000100001235",
65
+ "n_factura" => args[:n_factura] || "R000100001235",
66
+ "vencimiento" => args[:vencimiento] || "01/05/2011",
67
+ "gtin" => args[:gtin] || "GTIN2",
68
+ "lote" => args[:lote] || "1",
69
+ "desde_numero_serial" => args[:desde_numero_serial] || random_serial,
70
+ "hasta_numero_serial" => args[:hasta_numero_serial] || random_serial + 10,
71
+ "id_evento" => args[:id_evento] || "133",
72
+ "n_postal" => args[:n_postal] || "1416",
73
+ "telefono" => args[:telefono] || "45880712"
61
74
  },
62
- "arg1" => @user,
63
- "arg2" => @pass
75
+ "arg1" => @usuartio_laboratorio_2,
76
+ "arg2" => @pass_laboratorio_2
77
+ }
78
+
79
+ response = @client.call(:send_medicamentos_dh_serie, message: body)
80
+ return responder(response.body[:send_medicamentos_dh_serie_response])
81
+ end
82
+
83
+ def cancelar_transaccion(id)
84
+ set_client
85
+ body = {"arg0" => id, "arg1" => @usuartio_laboratorio_2, "arg2" => @pass_laboratorio_2}
86
+ response = @client.call(:send_cancelac_transacc, message: body)
87
+ return responder(response.body[:send_cancelac_transacc_response])
88
+ end
89
+
90
+ def consultar_stock(args={}, user, pass)
91
+ client = set_client
92
+ body = {
93
+ "arg0" => user,
94
+ "arg1" => pass,
95
+ "arg2" => args[:gtin] || 'GTIN1',
96
+ "arg3" => args[:gln] || 'glnws',
97
+ "arg4" => args[:medicine] || 'GTIN1',
98
+ "arg5" => args[:quantity] || 5,
99
+ "arg6" => args[:m_presentation],
100
+ "arg7" => args[:batch],
101
+ "arg8" => args[:serial],
102
+ "arg9" => args[:page],
103
+ "arg10" => args[:per_page]
104
+ }
105
+
106
+ response = @client.call(:get_consulta_stock, message: body)
107
+ end
108
+
109
+ def transacciones_no_confirmadas(args={})
110
+ set_client
111
+ body = {
112
+ "args0" => @usuario_laboratorio_1,
113
+ "args1" => @pass_laboratorio_1,
114
+ "args2" => args[:id_transaccion] || -1,
115
+ "args3" => args[:gln_informador],
116
+ "args4" => args[:gln_origen] || @gln_laboratorio_2,
117
+ "args5" => args[:gln_destino] || @gln_laboratorio_1,
118
+ "args6" => args[:gtin],
119
+ "args7" => args[:id_evento] || -1,
120
+ "args8" => args[:fecha_ope_dede],
121
+ "args9" => args[:fecha_ope_hasta],
122
+ "args10" => args[:fecha_trans_desde],
123
+ "args11" => args[:fecha_trans_hasta],
124
+ "args12" => args[:fecha_vencimiento_desde],
125
+ "args13" => args[:fecha_vencimiento_hasta],
126
+ "args14" => args[:n_remito],
127
+ "args15" => args[:n_factura],
128
+ "args16" => args[:estado_transaccion] || -1,
129
+ "args17" => args[:p1],
130
+ "args18" => args[:p2]
64
131
  }
132
+ response = @client.call(:get_transacciones_no_confirmadas, message: body)
133
+ return responder(response.body[:get_transacciones_no_confirmadas_response])
65
134
  end
66
135
  end
67
136
  end
@@ -1,5 +1,5 @@
1
1
  module Ruby
2
2
  module Anmat
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-anmat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ing. Díaz Martínez Facundo