biro 0.6.2 → 0.6.3

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: 45f40b95c01a1d2971041d9e9e94cf9cf287ba95
4
- data.tar.gz: 15ab535b27b623f3f37cac9c51550b781e679159
3
+ metadata.gz: 9b63fc7f5ea082401ccd01dace52d066fa3ecac5
4
+ data.tar.gz: e58611f6182db11cfe0c9074d95955dfe65063c6
5
5
  SHA512:
6
- metadata.gz: 478b281e994986c3ddd154388c187c96cea6820110e3fded83dd7b499fa8ac99b3e533bdf388431d70d2a5f10c95f34a96b47bc6a8725fa52be8879abdfb82d2
7
- data.tar.gz: 2c6b5acca488b74c4fa6aa6e0e2c659f93e1cd7a42e6ec970e891d0ba79edd349e1d16e4f5bdc6e918895acaeed74727af65f5bb3e2afd3e69aa792c1a4347cb
6
+ metadata.gz: e5b605828328753c07c5288787a0ca99d570f51a98b610650f50fadaea6f9f9bcb79f9b10949854819bbc563e56060aaa57136b572482713671b79d8c10f8361
7
+ data.tar.gz: d4cb54ed358e3f0f5eff6362ab6a65a38618b49052d982791971fc5a07bfe8030b5b6d06110de4914ddad1c8c070a3f875d277929853a6fd9bc2bc6f79ad6159
data/biro-0.6.2.gem ADDED
Binary file
@@ -34,15 +34,22 @@ module Biro
34
34
  def invoice_list
35
35
  return if operation_list.blank?
36
36
 
37
- list = []
38
- result.dig(:lista_de_resumo_das_operacoes)&.dig(:lista_de_vencimentos).each do |item|
39
- list.push({:code => item[:codigo_vencimento], :value => item[:valor_vencimento]})
37
+ Array.wrap(result.dig(:lista_de_resumo_das_operacoes)).map do |item|
38
+ {
39
+ :tax_variation => item[:variacao_cambial],
40
+ :modality => item[:modalidade],
41
+ :dues_list => invoice_list_item(item[:lista_de_vencimentos])
42
+ }
40
43
  end
41
- list
42
44
  end
43
45
 
44
- def exchange_rate_variation
45
- operation_list&.dig(:variacao_cambial)
46
+ def invoice_list_item(items)
47
+ Array.wrap(items).map do |item|
48
+ {
49
+ :code => item[:codigo_vencimento],
50
+ :value => item[:valor_vencimento]
51
+ }
52
+ end
46
53
  end
47
54
 
48
55
  def processed_documents_percentage
@@ -1,8 +1,8 @@
1
1
  module Biro
2
2
  module Bvs
3
3
  class DebitsResponseBuilder
4
- def initialize body
5
- @body = body.gsub("\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
4
+ def initialize(body)
5
+ @body = build(body)
6
6
  end
7
7
 
8
8
  def transaction
@@ -44,6 +44,10 @@ module Biro
44
44
  def debits_info
45
45
  response_text[6]
46
46
  end
47
+
48
+ def build(body)
49
+ body.gsub("\n", '').gsub("\t", '').gsub("\\t", '').gsub("\\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -1,8 +1,8 @@
1
1
  module Biro
2
2
  module Bvs
3
3
  class ScoreResponseBuilder
4
- def initialize body
5
- @body = body.gsub("\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
4
+ def initialize(body)
5
+ @body = build(body)
6
6
  end
7
7
 
8
8
  def transaction
@@ -92,6 +92,10 @@ module Biro
92
92
  def error_message
93
93
  response_text[8..100]
94
94
  end
95
+
96
+ def build(body)
97
+ body.gsub("\n", '').gsub("\t", '').gsub("\\t", '').gsub("\\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
98
+ end
95
99
  end
96
100
  end
97
101
  end
@@ -31,6 +31,10 @@ module Biro
31
31
 
32
32
  private
33
33
 
34
+ def savon_options
35
+ { strip_namespaces: false }
36
+ end
37
+
34
38
  def verify_response responses
35
39
  raise AuthenticationError.new("Error at Midia100 request: #{responses[:registration].body[:consultar_response][:consultar_result]}") if responses[:registration]&.body[:consultar_response][:consultar_result]&.include? "Usuário ou Senha Estão Incorretos"
36
40
  raise DocumentNotFoundError.new("Error at Midia100 request: #{responses[:registration].body[:consultar_response][:consultar_result]}") if responses[:registration]&.body[:consultar_response][:consultar_result]&.include? "Cpf Inválido"
@@ -159,7 +159,7 @@ module Biro
159
159
  end
160
160
 
161
161
  def result(data)
162
- Nori.new.parse(data[:consultar_response][:consultar_result])['NewDataSet'] unless data.nil?
162
+ Nori.new(convert_attributes_to: ->(key, value) { [] }).parse(data[:consultar_response][:consultar_result])['NewDataSet'] unless data.nil?
163
163
  end
164
164
  end
165
165
  end
@@ -25,6 +25,7 @@ module Biro
25
25
  Response.new(response)
26
26
  rescue => e
27
27
  Biro.log(:warn, "Unable to process Ph3a request")
28
+ raise AuthenticationError.new("Error at PH3A request: #{e.message}") if e.message.include?("User not authenticated")
28
29
  raise StandardError.new("Error at PH3A request: #{e.message}")
29
30
  end
30
31
  end
data/lib/biro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Biro
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noverde Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2017-07-27 00:00:00.000000000 Z
14
+ date: 2017-07-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: savon
@@ -145,6 +145,7 @@ files:
145
145
  - Rakefile
146
146
  - bin/console
147
147
  - bin/setup
148
+ - biro-0.6.2.gem
148
149
  - biro.gemspec
149
150
  - lib/biro.rb
150
151
  - lib/biro/configuration.rb