cobro_digital 1.2.1 → 1.3.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: 5c78fb34d01c8ee0797661f4987b3d8e91ffefb4
4
- data.tar.gz: abc54aede5e6e7b0e2dbbad45e69e64f81153ebb
3
+ metadata.gz: 02ddf257503cd550fc4b8a1583475c5f56a3c363
4
+ data.tar.gz: f577d7d9b881a5282c20a507598eff02af683002
5
5
  SHA512:
6
- metadata.gz: a582e44a64e0205301673380574e074e6aa2269fcfb36383fc54e3585fc9564719fe32806362bb11ab4768ae08e9c390a3aa8ee076d7a5a11fd197a0af9f24da
7
- data.tar.gz: 6d88a47bd0d4171ba64252114e528255e18b96b9b79a5b203555a1dbcc8aa04a8c0249412935778ba6be744342952dc29cd67676c5dcecd165e2e5eb499add65
6
+ metadata.gz: '098cd90720c214cff2cb970244a1c859854bcc778fa0c33235bfcc06c2536a82dfdb0ccd9f484890e4a5c05c9c8e3450da96587c249b4c915404d6660501ab82'
7
+ data.tar.gz: 204eb5352e5a3d52128b52a47c44e5d81f6000d18d29364f94c764b641c199cf70fee732a25f177a09d1eb104ace611c33411434105f11c5389037c474e2852d
@@ -27,14 +27,14 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "bundler", "~> 1.13"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "rspec"
32
+ # spec.add_development_dependency "rspec"
33
33
 
34
- spec.add_runtime_dependency(%q<savon>, ["= 2.4.0"])
34
+ spec.add_runtime_dependency 'savon', '~> 2.4'
35
35
 
36
- spec.add_dependency(%q<nokogiri>, ["~> 1.6"])
37
- spec.add_dependency(%q<wasabi>, ["~> 3.2.3"])
38
- spec.add_dependency(%q<akami>, ["~> 1.1"])
39
- spec.add_dependency(%q<nori>, ["~> 2.3.0"])
36
+ spec.add_dependency 'nokogiri', '~> 1.6'
37
+ spec.add_dependency 'wasabi', '~> 3.2'
38
+ spec.add_dependency 'akami', '~> 1.1'
39
+ spec.add_dependency 'nori', '~> 2.3'
40
40
  end
@@ -1,7 +1,7 @@
1
1
  module CobroDigital
2
2
  class Meta < CobroDigital::Operador
3
3
 
4
- META_WS = 'meta'
4
+ META_WS = 'meta'.freeze
5
5
 
6
6
  # md5(microtime(true)*rand())
7
7
  # { 'handshake'=>Digest::MD5.hexdigest(Time.now.to_f.to_s),
@@ -38,10 +38,58 @@ module CobroDigital
38
38
  # '5' => { 'metodo_webservice' => 'inhabilitar_boleta',
39
39
  # 'handshake' => Digest::MD5.hexdigest(Time.now.to_f.to_s),
40
40
  # 'nro_boleta' => '65' } }
41
- def self.meta(params)
42
- CobroDigital::Meta.new( :http_method => CobroDigital::Https::POST,
43
- :webservice => META_WS,
44
- :render => params )
41
+
42
+ def self.transaction(desde, hasta, filtros = {})
43
+ filter = {
44
+ ::CobroDigital::Transaccion::FILTRO_TIPO => ::CobroDigital::Transaccion::FILTRO_TIPO_INGRESO
45
+ }
46
+
47
+ filter.merge!(filtros) unless filtros.empty?
48
+
49
+ CobroDigital::Transaccion.consultar(
50
+ desde,
51
+ hasta,
52
+ filter
53
+ )
54
+ end
55
+
56
+ def self.render(objs)
57
+ querys = {}
58
+ objs.each_with_index do |obj, i|
59
+ querys[i] = obj.render.merge(metodo_webservice: obj.webservice)
60
+ end
61
+ querys
62
+ end
63
+
64
+ def self.meta(objs)
65
+ CobroDigital::Meta.new(
66
+ :http_method => CobroDigital::Https::POST,
67
+ :webservice => META_WS,
68
+ :render => render(objs)
69
+ )
70
+ end
71
+
72
+ def parse_response
73
+ output = response.body[:webservice_cobrodigital_response][:output]
74
+ parsed_response = JSON.parse(output)
75
+
76
+ datos = parsed_response['datos'].map do |data|
77
+ parsed_data = JSON.parse(data)
78
+
79
+ local_data = if parsed_data['datos'].present?
80
+ JSON.parse(parsed_data['datos'].first) rescue []
81
+ else
82
+ []
83
+ end
84
+
85
+ { resultado: (parsed_data['ejecucion_correcta'] == '1'),
86
+ log: parsed_data['log'],
87
+ datos: local_data }
88
+ end
89
+
90
+ { resultado: (parsed_response['ejecucion_correcta'] == '1'),
91
+ log: parsed_response['log'],
92
+ datos: datos }
45
93
  end
46
94
 
47
95
  end
@@ -1,21 +1,22 @@
1
1
  module CobroDigital
2
2
  class Operador
3
3
 
4
- attr_accessor :http_method, :webservice, :render, :response
4
+ attr_accessor :http_method, :webservice, :render, :response, :client
5
5
 
6
6
  def initialize(attrs={})
7
7
  @http_method = attrs[:http_method]
8
8
  @webservice = attrs[:webservice]
9
9
  @render = attrs[:render]
10
+ @client = nil
10
11
  end
11
12
 
12
13
  def request
13
14
  { :metodo_webservice => @webservice }.merge(render)
14
15
  end
15
16
 
16
- def call(id_comercio, sid, opt={})
17
- client = CobroDigital::Client.new(opt.merge(:id_comercio => id_comercio, :sid => sid, :http_method => http_method))
18
- @response = client.call(request)
17
+ def call(id_comercio, sid, opt = {})
18
+ @client = CobroDigital::Client.new(opt.merge(:id_comercio => id_comercio, :sid => sid, :http_method => http_method))
19
+ @response = @client.call(request)
19
20
  end
20
21
 
21
22
  def parse_response
@@ -15,13 +15,21 @@ module CobroDigital
15
15
  FILTRO_TIPO_TARJETA_CREDITO = 'tarjeta_credito' # Solo aquellas cobranzas abonadas con tarjeta de crédito.
16
16
  FILTRO_TIPO_DEBITO_AUTOMATICO = 'debito_automatico' # Está relacionado a los débitos realizados por CBU.
17
17
 
18
+ def self.render(desde, hasta, filtros = {})
19
+ {
20
+ :desde => desde.strftime('%Y%m%d'),
21
+ :hasta => hasta.strftime('%Y%m%d'),
22
+ :filtros => filtros
23
+ }
24
+ end
25
+
18
26
  # { 'desde'=>'20160932', 'hasta'=>'20161001' }
19
- def self.consultar(desde, hasta, filtros={})
20
- CobroDigital::Transaccion.new( :http_method => CobroDigital::Https::GET,
21
- :webservice => CONSULTAR_TRANSACCIONES_WS,
22
- :render => { :desde => desde.strftime('%Y%m%d'),
23
- :hasta => hasta.strftime('%Y%m%d'),
24
- :filtros => filtros } )
27
+ def self.consultar(desde, hasta, filtros = {})
28
+ CobroDigital::Transaccion.new(
29
+ :http_method => CobroDigital::Https::GET,
30
+ :webservice => CONSULTAR_TRANSACCIONES_WS,
31
+ :render => render(desde, hasta, filtros)
32
+ )
25
33
  end
26
34
 
27
35
  def parse_response
@@ -1,3 +1,3 @@
1
1
  module CobroDigital
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/cobro_digital.rb CHANGED
@@ -24,7 +24,7 @@ module CobroDigital
24
24
 
25
25
  class Client
26
26
 
27
- attr_accessor :id_comercio, :sid, :client_to_use, :http_method, :pagadores, :boletas, :transacciones, :micrositios, :requests
27
+ attr_accessor :id_comercio, :sid, :client_to_use, :http_method, :pagadores, :boletas, :transacciones, :micrositios, :requests, :request_xml
28
28
 
29
29
  def initialize(attrs={})
30
30
  @id_comercio = attrs[:id_comercio]
@@ -35,10 +35,14 @@ module CobroDigital
35
35
  @boletas = []
36
36
  @transacciones = []
37
37
  @micrositios = []
38
+ @request_xml = nil
38
39
  end
39
40
 
40
41
  def soap_client(params)
41
- client = Savon.client( wsdl: CobroDigital::WSDL, log_level: :debug, pretty_print_xml: true)
42
+ client = Savon.client(wsdl: CobroDigital::WSDL, log_level: :debug, pretty_print_xml: true)
43
+ operation = client.operation(:webservice_cobrodigital)
44
+ request = operation.build(message: { 'parametros_de_entrada' => params.to_json })
45
+ @request_xml = request.pretty
42
46
  client.call(:webservice_cobrodigital, message: { 'parametros_de_entrada' => params.to_json })
43
47
  end
44
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobro_digital
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - g.edera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-09 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.13'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,34 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: savon
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '='
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 2.4.0
47
+ version: '2.4'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - '='
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 2.4.0
54
+ version: '2.4'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: nokogiri
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +72,14 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 3.2.3
75
+ version: '3.2'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 3.2.3
82
+ version: '3.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: akami
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 2.3.0
103
+ version: '2.3'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 2.3.0
110
+ version: '2.3'
125
111
  description: Adaptador para el Web Service de CobroDigital
126
112
  email:
127
113
  - gab.edera@gmail.com
@@ -168,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
154
  version: '0'
169
155
  requirements: []
170
156
  rubyforge_project:
171
- rubygems_version: 2.6.11
157
+ rubygems_version: 2.6.14
172
158
  signing_key:
173
159
  specification_version: 4
174
160
  summary: Adaptador CobroDigital