zaig 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zaig/already_exists_error.rb +1 -1
- data/lib/zaig/external_timeout_error.rb +1 -1
- data/lib/zaig/field_validation_error.rb +1 -1
- data/lib/zaig/registration.rb +8 -6
- data/lib/zaig/registration_payload.rb +17 -9
- data/lib/zaig/server_error.rb +1 -1
- data/lib/zaig/server_timeout_error.rb +1 -1
- data/lib/zaig/unexpected_error.rb +1 -1
- data/lib/zaig/unprocessable_entity_error.rb +1 -1
- data/lib/zaig/validation_error.rb +1 -1
- data/lib/zaig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab0151c32beb57d31bb2e3ccd10ff6408091c79c61dbbb9f85b03fed94b6498b
|
4
|
+
data.tar.gz: dc88f4a1dbb7601abddeb3c8812948a1f3c6b9633d1b6899168530831b125b4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d241a7a4b5124573f7b45d5a5818075fe45b117bce2ee3d21b404c009eeb9d2f4dbeeff52f6386841c204b568b71811cad6376f23295876645a9a011fd9a1c
|
7
|
+
data.tar.gz: d761bbadde669244ad80a1644d31350796f2d1e77ea6d2e01b29cf243b7f691f26d28a49675f37567a74a5d88d1c23403fbaa42044b49afbef2121aa918885aa
|
data/lib/zaig/registration.rb
CHANGED
@@ -56,7 +56,9 @@ module Zaig
|
|
56
56
|
raise error
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
title = parsed_res[:resposta_zaig][:conteudo][:title]
|
60
|
+
description = parsed_res[:resposta_zaig][:conteudo][:description]
|
61
|
+
zaig_msg = "#{title}: #{description}"
|
60
62
|
zaig_http_status = parsed_res[:resposta_zaig][:status]
|
61
63
|
|
62
64
|
raise_error_by_zaig_status(zaig_msg, zaig_http_status)
|
@@ -65,15 +67,15 @@ module Zaig
|
|
65
67
|
def raise_error_by_zaig_status(msg, status)
|
66
68
|
case status
|
67
69
|
when 400
|
68
|
-
raise ::Zaig::FieldValidationError
|
70
|
+
raise ::Zaig::FieldValidationError.new msg
|
69
71
|
when 408
|
70
|
-
raise ::Zaig::ExternalTimeoutError
|
72
|
+
raise ::Zaig::ExternalTimeoutError.new msg
|
71
73
|
when 409
|
72
|
-
raise ::Zaig::AlreadyExistsError
|
74
|
+
raise ::Zaig::AlreadyExistsError.new msg
|
73
75
|
when 422
|
74
|
-
raise ::Zaig::UnprocessableEntityError
|
76
|
+
raise ::Zaig::UnprocessableEntityError.new msg
|
75
77
|
else
|
76
|
-
raise ::Zaig::UnexpectedError
|
78
|
+
raise ::Zaig::UnexpectedError.new msg
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
@@ -6,7 +6,7 @@ module Zaig
|
|
6
6
|
include Singleton
|
7
7
|
|
8
8
|
def call(obj)
|
9
|
-
{
|
9
|
+
payload = {
|
10
10
|
address: build_address(obj[:address]),
|
11
11
|
client_category: obj[:client_category],
|
12
12
|
constitution_date: obj[:constitution_date],
|
@@ -15,18 +15,19 @@ module Zaig
|
|
15
15
|
credit_type: obj[:credit_type] || "clean",
|
16
16
|
document_number: CNPJ.new(obj[:document_number]).formatted,
|
17
17
|
email: obj[:email],
|
18
|
-
financial: obj.key?("financial") ? build_financial(obj[:financial]) : nil,
|
19
|
-
guarantors: obj.key?("guarantors") ? build_shareholders(obj[:guarantors]) : nil,
|
20
18
|
id: obj[:id],
|
21
19
|
legal_name: obj[:legal_name],
|
22
20
|
monthly_revenue: format_money(obj[:monthly_revenue], require_positive: true),
|
23
21
|
phones: build_phones(obj[:phones]),
|
24
22
|
shareholders: build_shareholders(obj[:shareholders]),
|
25
|
-
|
26
|
-
scr_parameters: obj.key?("scr_parameters") ? build_scr_parameters(obj[:scr_parameters]) : nil,
|
27
|
-
trading_name: obj[:trading_name],
|
28
|
-
warrants: obj.key?("warrants") ? build_warrants(obj[:warrants]) : nil
|
23
|
+
trading_name: obj[:trading_name]
|
29
24
|
}
|
25
|
+
payload[:guarantors] = build_shareholders(obj[:guarantors]) if obj.key?(:guarantors)
|
26
|
+
payload[:financial] = build_financial(obj[:financial]) if obj.key?(:financial)
|
27
|
+
payload[:scr_parameters] = build_scr_parameters(obj[:scr_parameters]) if obj.key?(:scr_parameters)
|
28
|
+
payload[:source] = build_source(obj[:source]) if obj.key?(:source)
|
29
|
+
payload[:warrants] = build_warrants(obj[:warrants]) if obj.key?(:warrants)
|
30
|
+
payload
|
30
31
|
end
|
31
32
|
|
32
33
|
private
|
@@ -76,10 +77,10 @@ module Zaig
|
|
76
77
|
declared_assets: format_money(s[:declared_assets]),
|
77
78
|
document_number: CPF.new(s[:document_number]).formatted,
|
78
79
|
email: s[:email],
|
79
|
-
father_name: s[:father_name],
|
80
|
+
father_name: filter_blank(s[:father_name]),
|
80
81
|
gender: s[:gender],
|
81
82
|
monthly_income: format_money(s[:monthly_income]),
|
82
|
-
mother_name: s[:mother_name],
|
83
|
+
mother_name: filter_blank(s[:mother_name]),
|
83
84
|
name: s[:name],
|
84
85
|
nationality: s[:nationality],
|
85
86
|
occupation: s[:occupation],
|
@@ -161,7 +162,14 @@ module Zaig
|
|
161
162
|
signers
|
162
163
|
end
|
163
164
|
|
165
|
+
def filter_blank(value)
|
166
|
+
return value if value.nil?
|
167
|
+
|
168
|
+
value.strip == "" ? nil : value
|
169
|
+
end
|
170
|
+
|
164
171
|
def format_cep(cep)
|
172
|
+
cep = cep.delete("-")
|
165
173
|
cep.gsub(/[^0-9]/, "").insert(5, "-")
|
166
174
|
end
|
167
175
|
end
|
data/lib/zaig/server_error.rb
CHANGED
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.6"
|
12
12
|
end
|
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.6
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cpf_cnpj
|