cobro_digital 1.0.0 → 1.1.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.
data/README.md CHANGED
@@ -159,7 +159,6 @@ Obtener el string de los códigos de barras. Serán tantos como vencimientos e i
159
159
  Para la obtención de los códigos de barra es necesario comunicar:
160
160
  * numero de boleta (obtenida en la generación)
161
161
 
162
-
163
162
  ```ruby
164
163
  comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
165
164
  comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
@@ -199,6 +198,8 @@ filtro = { CobroDigital.Transaccion::FILTRO_TIPO => CobroDigital.Transa
199
198
  CobroDigital.Transaccion::FILTRO_IDENTIFICADOR => "Algun identificar" }
200
199
  ```
201
200
 
201
+ En el siguiente ejemplo se consultan todas las transacciones de ingreso.
202
+
202
203
  ```ruby
203
204
  comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
204
205
  comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
@@ -209,13 +210,30 @@ transacciones.call(comercio_id, comercio_sid)
209
210
  transacciones.response # Obtengo el resultado.
210
211
  ```
211
212
 
212
- ## SOAP vs HTTPS
213
+ ## Respuesta y Parser de Respuesta
214
+ La response proveniente del WS de CobroDigital siempre consiste en un JSON, donde los datos relevantes son:
215
+ * resultado: Si fue correcta la consulta realizada.
216
+ * log: En caso de no ser exitosa la consulta, mostrara los errores de la misma.
217
+ * datos: Resultado obtenido de la consulta (Es opcional, depende de la consulta)
218
+
219
+ El metodo _call_ guarda el resultado de la comunicación en el atributo **response** del objeto, por lo que siempres sera posible consultar la **Response**.
220
+
221
+ A traves del metodo **parse_response** es posible obenter la respuesta parseada en formato hash. Este metodo debe llamarse luego de haberse ejecutado el _call_,
222
+
223
+ ```ruby
224
+ comercio_id = 'HA765587' #Brindado por cobrodigital para realizar pruebas
225
+ comercio_sid = 'wsZ0ya68K791phuu76gQ5L662J6F2Y4j7zqE2Jxa3Mvd22TWNn4iip6L9yq' #Brindado por cobrodigital para realizar pruebas
226
+ numero_boleta = 123
227
+ boleta = CobroDigital.Boleta.obtener_codigo_de_barras(numero_boleta)
228
+ boleta.call(comercio_id, comercio_sid)
229
+ boleta.parse_response
213
230
 
214
- ## Development
231
+ { :resultado => true, :log => ["Codigos de barra de la boleta encontrados correctamente."], :datos => ["73852040502403101111600000002"] }
232
+ ```
215
233
 
216
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
234
+ ## SOAP vs HTTPS
217
235
 
218
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
236
+ En construcción.
219
237
 
220
238
  ## Contributing
221
239
 
@@ -18,5 +18,21 @@ module CobroDigital
18
18
  @response = client.call(request)
19
19
  end
20
20
 
21
+ def parse_response
22
+ parsed_response = JSON.parse(response.body[:webservice_cobrodigital_response][:output])
23
+
24
+ datos = []
25
+
26
+ if parsed_response['datos'].present?
27
+ parsed_response['datos'].each do |data|
28
+ _data = data.split("\"")
29
+ _data.delete("")
30
+ datos << _data
31
+ end
32
+ end
33
+
34
+ { status: (parsed_response['ejecucion_correcta'] == '1'), log: parsed_response['log'], datos: datos.flatten }
35
+ end
36
+
21
37
  end
22
38
  end
@@ -24,5 +24,14 @@ module CobroDigital
24
24
  :filtros => filtros } )
25
25
  end
26
26
 
27
+ def parse_response
28
+ output = response.body[:webservice_cobrodigital_response][:output]
29
+ parsed_response = JSON.parse(output)
30
+
31
+ datos = parsed_response['datos'].present? ? (JSON.parse(JSON.parse(output)['datos'].first) rescue []) : []
32
+
33
+ { status: (parsed_response['ejecucion_correcta'] == '1'), log: parsed_response['log'], datos: datos }
34
+ end
35
+
27
36
  end
28
37
  end
@@ -1,3 +1,3 @@
1
1
  module CobroDigital
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobro_digital
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - g.edera