zaig 1.0.7 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zaig/connection.rb +1 -1
- data/lib/zaig/registration.rb +3 -5
- data/lib/zaig/registration_payload.rb +14 -15
- data/lib/zaig/version.rb +1 -1
- data/lib/zaig.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c167ec0df18b273efccaa3a917a0295d32d7fc898a3f8787bc7af20616d142
|
4
|
+
data.tar.gz: b8825e48c786235fc7168bea2f5d4b43cb551e81b63cc5e5851b857b8b0cc2f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c1b0f6146ca518641e4021f209ba3c15946fc8d38b4a080eaec20b0fe852a28a50c03f0eebde5dffb7e81c2f06f934f89fa4857b0dca156c4af4c11ab2fd58
|
7
|
+
data.tar.gz: a35126e8b604ebba65e084aa44f6805fdcbe999b53d33599a77d28f8d6dfaaa425f52b360b86389c96fa67d01b4e3ae3c430393b7ba427d3c26d78a857f6e7a8
|
data/lib/zaig/connection.rb
CHANGED
data/lib/zaig/registration.rb
CHANGED
@@ -5,11 +5,9 @@ module Zaig
|
|
5
5
|
class Registration
|
6
6
|
attr_reader :connection
|
7
7
|
|
8
|
-
include Singleton
|
9
|
-
|
10
8
|
ENDPOINT = "zaig/consulta_de_credito"
|
11
9
|
|
12
|
-
def initialize(connection: Zaig::Connection.new, registration_payload: Zaig::RegistrationPayload.
|
10
|
+
def initialize(connection: Zaig::Connection.new, registration_payload: Zaig::RegistrationPayload.new)
|
13
11
|
@connection = connection
|
14
12
|
@registration_payload = registration_payload
|
15
13
|
end
|
@@ -48,8 +46,8 @@ module Zaig
|
|
48
46
|
unless parsed_res.key?(:resposta_zaig)
|
49
47
|
detail = JSON.parse(res.body, symbolize_names: true)[:detail]
|
50
48
|
|
51
|
-
error = ::Zaig::FieldValidationError.new I18n.t("zaig.errors.validation_error"
|
52
|
-
error.detail =
|
49
|
+
error = ::Zaig::FieldValidationError.new I18n.t("zaig.errors.validation_error")
|
50
|
+
error.detail = detail
|
53
51
|
|
54
52
|
raise error
|
55
53
|
end
|
@@ -3,30 +3,28 @@
|
|
3
3
|
module Zaig
|
4
4
|
# Service class to build a registration payload request.
|
5
5
|
class RegistrationPayload
|
6
|
-
include Singleton
|
7
|
-
|
8
6
|
def call(obj)
|
9
7
|
payload = {
|
10
|
-
address: build_address(obj[:address]),
|
11
8
|
client_category: obj[:client_category],
|
12
|
-
constitution_date: obj[:constitution_date],
|
13
|
-
constitution_type: obj[:constitution_type],
|
14
9
|
credit_request_date: obj[:credit_request_date],
|
15
10
|
credit_type: obj[:credit_type] || "clean",
|
16
11
|
document_number: CNPJ.new(obj[:document_number]).formatted,
|
17
|
-
email: obj[:email],
|
18
12
|
id: obj[:id],
|
19
13
|
legal_name: obj[:legal_name],
|
20
14
|
monthly_revenue: format_money(obj[:monthly_revenue], require_positive: true),
|
21
|
-
phones: build_phones(obj[:phones]),
|
22
|
-
shareholders: build_shareholders(obj[:shareholders]),
|
23
15
|
trading_name: obj[:trading_name]
|
24
16
|
}
|
25
|
-
payload[:
|
26
|
-
payload[:
|
27
|
-
payload[:
|
28
|
-
payload[:
|
29
|
-
payload[:
|
17
|
+
payload[:address] = build_address(obj[:address]) if obj[:address]
|
18
|
+
payload[:constitution_date] = obj[:constitution_date] if obj[:constitution_date]
|
19
|
+
payload[:constitution_type] = obj[:constitution_type] if obj[:constitution_type]
|
20
|
+
payload[:email] = obj[:email] if obj[:email]
|
21
|
+
payload[:financial] = build_financial(obj[:financial]) if obj[:financial]
|
22
|
+
payload[:guarantors] = build_shareholders(obj[:guarantors]) if obj[:guarantors]
|
23
|
+
payload[:phones] = build_phones(obj[:phones]) if obj[:phones]
|
24
|
+
payload[:scr_parameters] = build_scr_parameters(obj[:scr_parameters]) if obj[:scr_parameters]
|
25
|
+
payload[:shareholders] = build_shareholders(obj[:shareholders]) if obj[:shareholders]
|
26
|
+
payload[:source] = build_source(obj[:source]) if obj[:source]
|
27
|
+
payload[:warrants] = build_warrants(obj[:warrants]) if obj[:warrants]
|
30
28
|
payload
|
31
29
|
end
|
32
30
|
|
@@ -36,9 +34,8 @@ module Zaig
|
|
36
34
|
end
|
37
35
|
|
38
36
|
def build_address(obj_address)
|
39
|
-
{
|
37
|
+
address = {
|
40
38
|
city: obj_address[:city],
|
41
|
-
complement: obj_address[:complement] || "",
|
42
39
|
country: obj_address[:country] || "BRA",
|
43
40
|
neighborhood: obj_address[:neighborhood],
|
44
41
|
number: obj_address[:number],
|
@@ -46,6 +43,8 @@ module Zaig
|
|
46
43
|
street: obj_address[:street],
|
47
44
|
uf: obj_address[:uf]
|
48
45
|
}
|
46
|
+
address[:complement] = obj_address[:complement] if !obj_address[:complement].nil? || !obj_address[:complement]&.empty?
|
47
|
+
address
|
49
48
|
end
|
50
49
|
|
51
50
|
def build_phone(obj)
|
data/lib/zaig/version.rb
CHANGED
@@ -8,5 +8,5 @@ module Zaig
|
|
8
8
|
# Major - Incremented for incompatible changes with previous release (or big enough new features)
|
9
9
|
# Minor - Incremented for new backwards-compatible features + deprecations
|
10
10
|
# Patch - Incremented for backwards-compatible bug fixes
|
11
|
-
VERSION = "1.0.
|
11
|
+
VERSION = "1.0.10"
|
12
12
|
end
|
data/lib/zaig.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Carolino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cpf_cnpj
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: singleton
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: bundler
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|