biro 0.5.1 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/biro/gateways/bacen/response.rb +6 -13
- data/lib/biro/gateways/bvs/builders/base_builder.rb +16 -12
- data/lib/biro/gateways/bvs/builders/debits_request_builder.rb +25 -21
- data/lib/biro/gateways/bvs/builders/debits_response_builder.rb +47 -43
- data/lib/biro/gateways/bvs/builders/score_request_builder.rb +25 -21
- data/lib/biro/gateways/bvs/builders/score_response_builder.rb +95 -91
- data/lib/biro/gateways/midia100/request.rb +0 -4
- data/lib/biro/gateways/midia100/response.rb +1 -1
- data/lib/biro/gateways/ph3a/builders/login_builder.rb +14 -10
- data/lib/biro/gateways/ph3a/request.rb +0 -1
- data/lib/biro/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85d643740f0ac819800593ecdab3bafb8ece684
|
4
|
+
data.tar.gz: d68b592260971cba15ee315bd937f3bf277caf0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df77c24d783785e5f79d2e76259856e9ba08fe99311ef7fc70f4c0a3f9d86df65aa686536720701fb942e3fa89e0fb83162a12075c8b9d26fb5a7458256b59e6
|
7
|
+
data.tar.gz: 5f1ab66871ff3d83cca9bb39b46cfd0601b6a452806a40b17d4a01a7926bd98629567ab3e2914a48d83fe7f6f86aeac763d518e4de9dbee970128f665e5d376c
|
@@ -34,22 +34,15 @@ module Biro
|
|
34
34
|
def invoice_list
|
35
35
|
return if operation_list.blank?
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
:modality => item[:modalidade],
|
41
|
-
:dues_list => invoice_list_item(item[:lista_de_vencimentos])
|
42
|
-
}
|
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]})
|
43
40
|
end
|
41
|
+
list
|
44
42
|
end
|
45
43
|
|
46
|
-
def
|
47
|
-
|
48
|
-
{
|
49
|
-
:code => item[:codigo_vencimento],
|
50
|
-
:value => item[:valor_vencimento]
|
51
|
-
}
|
52
|
-
end
|
44
|
+
def exchange_rate_variation
|
45
|
+
operation_list&.dig(:variacao_cambial)
|
53
46
|
end
|
54
47
|
|
55
48
|
def processed_documents_percentage
|
@@ -1,17 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Biro
|
2
|
+
module Bvs
|
3
|
+
class BaseBuilder
|
4
|
+
def initialize document, username, password
|
5
|
+
@document = document
|
6
|
+
@username = username
|
7
|
+
@password = password
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def build
|
11
|
+
raise "This method must be implemented"
|
12
|
+
end
|
11
13
|
|
12
|
-
|
14
|
+
protected
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
def build_string
|
17
|
+
@parameters.values.map { |p| p[:type] == "T" ? p[:value].to_s.ljust(p[:size], " ") : p[:value].to_s.rjust(p[:size],"0") }.join
|
18
|
+
end
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -1,26 +1,30 @@
|
|
1
1
|
require_relative 'base_builder'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
module Biro
|
4
|
+
module Bvs
|
5
|
+
class DebitsRequestBuilder < BaseBuilder
|
6
|
+
def build
|
7
|
+
@parameters = {
|
8
|
+
transaction: { size: 8, type: "T", value: "CSR60" },
|
9
|
+
version: { size: 2, type: "T", value: "01" },
|
10
|
+
reserved_applicant: { size: 10, type: "T", value: "" },
|
11
|
+
reserved_bvs: { size: 20, type: "T", value: "" },
|
12
|
+
service_code: { size: 8, type: "N", value: @username },
|
13
|
+
password: { size: 8, type: "T", value: @password },
|
14
|
+
search_type: { size: 8, type: "T", value: "SPCIT" },
|
15
|
+
reserverd_bvs_2: { size: 4, type: "T", value: ""},
|
16
|
+
response_type: { size: 1, type: "T", value: "2" },
|
17
|
+
document_type: { size: 1, type: "T", value: "1" },
|
18
|
+
document: { size: 14, type: "N", value: @document },
|
19
|
+
reserverd_bvs_3: { size: 235, type: "T", value: ""},
|
20
|
+
facilitator_code: { size: 8, type: "N", value: "" },
|
21
|
+
reserverd_bvs_4: { size: 2, type: "T", value: ""},
|
22
|
+
response_trans_type: { size: 1, type: "T", value: "C" },
|
23
|
+
finish_marker: { size: 1, type: "T", value: "X" }
|
24
|
+
}
|
23
25
|
|
24
|
-
|
26
|
+
build_string
|
27
|
+
end
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
@@ -1,45 +1,49 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
module Biro
|
2
|
+
module Bvs
|
3
|
+
class DebitsResponseBuilder
|
4
|
+
def initialize body
|
5
|
+
@body = body.gsub("\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
|
6
|
+
end
|
7
|
+
|
8
|
+
def transaction
|
9
|
+
@body[0..7]
|
10
|
+
end
|
11
|
+
|
12
|
+
def version
|
13
|
+
@body[8..9]
|
14
|
+
end
|
15
|
+
|
16
|
+
def reserved_applicant
|
17
|
+
@body[10..19]
|
18
|
+
end
|
19
|
+
|
20
|
+
def reserved_bvs
|
21
|
+
@body[20..39]
|
22
|
+
end
|
23
|
+
|
24
|
+
def response_type
|
25
|
+
@body[56]
|
26
|
+
end
|
27
|
+
|
28
|
+
def return_code
|
29
|
+
@body[57]
|
30
|
+
end
|
31
|
+
|
32
|
+
def response_text_size
|
33
|
+
@body[58..61].to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
def response_text
|
37
|
+
@body[62,response_text_size]
|
38
|
+
end
|
39
|
+
|
40
|
+
def error_message
|
41
|
+
response_text[8..100]
|
42
|
+
end
|
43
|
+
|
44
|
+
def debits_info
|
45
|
+
response_text[6]
|
46
|
+
end
|
47
|
+
end
|
44
48
|
end
|
45
49
|
end
|
@@ -1,24 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
module Biro
|
2
|
+
module Bvs
|
3
|
+
class ScoreRequestBuilder < BaseBuilder
|
4
|
+
def build
|
5
|
+
@parameters = {
|
6
|
+
transaction: { size: 8, type: "T", value: "CSR60" },
|
7
|
+
version: { size: 2, type: "T", value: "01" },
|
8
|
+
reserved_applicant: { size: 10, type: "T", value: "" },
|
9
|
+
reserved_bvs: { size: 20, type: "T", value: "" },
|
10
|
+
service_code: { size: 8, type: "N", value: @username },
|
11
|
+
password: { size: 8, type: "T", value: @password },
|
12
|
+
search_type: { size: 8, type: "T", value: "SCORE" },
|
13
|
+
search_version: { size: 2, type: "T", value: "04" },
|
14
|
+
response_type: { size: 1, type: "T", value: "2" },
|
15
|
+
response_trans_type: { size: 1, type: "T", value: "C" },
|
16
|
+
document_type: { size: 1, type: "T", value: "1" },
|
17
|
+
document: { size: 14, type: "N", value: @document },
|
18
|
+
score_model: { size: 2, type: "T", value: "63" },
|
19
|
+
source_cep: { size: 8, type: "N", value: "" },
|
20
|
+
facilitator_code: { size: 8, type: "N", value: "" },
|
21
|
+
finish_marker: { size: 1, type: "T", value: "X" }
|
22
|
+
}
|
21
23
|
|
22
|
-
|
24
|
+
build_string
|
25
|
+
end
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,93 +1,97 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
1
|
+
module Biro
|
2
|
+
module Bvs
|
3
|
+
class ScoreResponseBuilder
|
4
|
+
def initialize body
|
5
|
+
@body = body.gsub("\n", '').scan(/<PRE>([^<>]*)<\/PRE>/imu).flatten[0]
|
6
|
+
end
|
7
|
+
|
8
|
+
def transaction
|
9
|
+
@body[0..7]
|
10
|
+
end
|
11
|
+
|
12
|
+
def version
|
13
|
+
@body[8..9]
|
14
|
+
end
|
15
|
+
|
16
|
+
def reserved_applicant
|
17
|
+
@body[10..19]
|
18
|
+
end
|
19
|
+
|
20
|
+
def reserved_bvs
|
21
|
+
@body[20..39]
|
22
|
+
end
|
23
|
+
|
24
|
+
def service_code
|
25
|
+
@body[40..47]
|
26
|
+
end
|
27
|
+
|
28
|
+
def search_type
|
29
|
+
@body[48..55]
|
30
|
+
end
|
31
|
+
|
32
|
+
def search_version
|
33
|
+
@body[56..57]
|
34
|
+
end
|
35
|
+
|
36
|
+
def response_type
|
37
|
+
@body[58]
|
38
|
+
end
|
39
|
+
|
40
|
+
def return_code
|
41
|
+
@body[59]
|
42
|
+
end
|
43
|
+
|
44
|
+
def search_number
|
45
|
+
@body[60..66]
|
46
|
+
end
|
47
|
+
|
48
|
+
def response_text_size
|
49
|
+
@body[67..70].to_i
|
50
|
+
end
|
51
|
+
|
52
|
+
def response_text
|
53
|
+
@body[71,response_text_size]
|
54
|
+
end
|
55
|
+
|
56
|
+
def response_text_init
|
57
|
+
response_text[0..2]
|
58
|
+
end
|
59
|
+
|
60
|
+
def response_text_type
|
61
|
+
response_text[3..5]
|
62
|
+
end
|
63
|
+
|
64
|
+
def response_text_is_present
|
65
|
+
response_text[6]
|
66
|
+
end
|
67
|
+
|
68
|
+
def response_text_document_type
|
69
|
+
response_text[7]
|
70
|
+
end
|
71
|
+
|
72
|
+
def response_text_document
|
73
|
+
response_text[8..21]
|
74
|
+
end
|
75
|
+
|
76
|
+
def response_text_name
|
77
|
+
response_text[22..136]
|
78
|
+
end
|
79
|
+
|
80
|
+
def response_text_result_score
|
81
|
+
response_text[137..140]
|
82
|
+
end
|
83
|
+
|
84
|
+
def response_text_description
|
85
|
+
response_text[141..160]
|
86
|
+
end
|
87
|
+
|
88
|
+
def response_text_over
|
89
|
+
response_text[160..500]
|
90
|
+
end
|
91
|
+
|
92
|
+
def error_message
|
93
|
+
response_text[8..100]
|
94
|
+
end
|
95
|
+
end
|
92
96
|
end
|
93
97
|
end
|
@@ -31,10 +31,6 @@ module Biro
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def savon_options
|
35
|
-
{ strip_namespaces: false }
|
36
|
-
end
|
37
|
-
|
38
34
|
def verify_response responses
|
39
35
|
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"
|
40
36
|
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
|
162
|
+
Nori.new.parse(data[:consultar_response][:consultar_result])['NewDataSet'] unless data.nil?
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'active_support/core_ext/array'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Biro
|
4
|
+
module Ph3a
|
5
|
+
class LoginBuilder
|
6
|
+
def initialize response
|
7
|
+
@body = response.body
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def token
|
11
|
+
login_result.dig(:token)
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
def login_result
|
15
|
+
@body.dig(:login_response).dig(:login_result)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
15
19
|
end
|
@@ -25,7 +25,6 @@ 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")
|
29
28
|
raise StandardError.new("Error at PH3A request: #{e.message}")
|
30
29
|
end
|
31
30
|
end
|
data/lib/biro/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.1
|
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-
|
14
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: savon
|