zaig 1.0.0 → 1.0.3
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.
- checksums.yaml +4 -4
- data/lib/zaig/registration.rb +6 -2
- data/lib/zaig/registration_payload.rb +16 -4
- data/lib/zaig/version.rb +1 -1
- data/lib/zaig.rb +1 -14
- metadata +2 -18
- data/lib/config/settings/development.yml +0 -5
- data/lib/config/settings/production.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00531b692d17cf8b508317410d44fd193c247f49b73579f1c836199e457a43c1
|
4
|
+
data.tar.gz: b156aa4e304031c1c65397ac458e9430038d84c7223352b7add307551ee9348d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da7e1c681ab55b6ace31c91cda4514076ffb414c8cbfffb98325514c2dafb46b9528c7608169082aa7b4ef89b2caf95a7210835f56fce796b4f7c7d55df022e
|
7
|
+
data.tar.gz: 1e7ef1819184ec0c8a208e7b7b546f4fdd14ac58ef926d029a9ee9c55f3a3d1834b31273a84f32d2d254fb5c122a499dadb8207548c3b1ca03e2a57cd80c146f
|
data/lib/zaig/registration.rb
CHANGED
@@ -9,15 +9,19 @@ module Zaig
|
|
9
9
|
|
10
10
|
include Singleton
|
11
11
|
|
12
|
+
ENDPOINT = "zaig/consulta_de_credito"
|
13
|
+
|
12
14
|
def initialize(connection: Zaig::Connection.new, registration_payload: Zaig::RegistrationPayload.instance)
|
13
15
|
@connection = connection
|
14
16
|
@registration_payload = registration_payload
|
15
17
|
end
|
16
18
|
|
17
19
|
def call(obj)
|
18
|
-
endpoint = Zaig.configuration.defaults.api.endpoints.inquiry.credit.freeze
|
19
20
|
payload = @registration_payload.call(obj)
|
20
|
-
|
21
|
+
|
22
|
+
req_endpoint = Zaig.configuration.registration_endpoint
|
23
|
+
|
24
|
+
res = @connection.post(url: (req_endpoint.nil? ? ENDPOINT : req_endpoint), body: payload.to_json)
|
21
25
|
|
22
26
|
verify_response(res)
|
23
27
|
|
@@ -11,7 +11,7 @@ module Zaig
|
|
11
11
|
{
|
12
12
|
address: build_address(obj["address"]),
|
13
13
|
client_category: obj["client_category"],
|
14
|
-
constitution_date: obj["constitution_date"],
|
14
|
+
constitution_date: Date.parse(obj["constitution_date"]).to_s,
|
15
15
|
constitution_type: obj["constitution_type"],
|
16
16
|
credit_request_date: obj["credit_request_date"],
|
17
17
|
credit_type: obj["credit_type"] || "clean",
|
@@ -24,10 +24,10 @@ module Zaig
|
|
24
24
|
monthly_revenue: obj["monthly_revenue"].to_f,
|
25
25
|
phones: build_phones(obj["phones"]),
|
26
26
|
shareholders: build_shareholders(obj["shareholders"]),
|
27
|
-
source: build_source(obj["source"]),
|
28
|
-
scr_parameters: build_scr_parameters(obj["scr_parameters"]),
|
27
|
+
source: obj.key?("source") ? build_source(obj["source"]) : nil,
|
28
|
+
scr_parameters: obj.key?("scr_parameters") ? build_scr_parameters(obj["scr_parameters"]) : nil,
|
29
29
|
trading_name: obj["trading_name"],
|
30
|
-
warrants: build_warrants(obj["warrants"])
|
30
|
+
warrants: obj.key?("warrants") ? build_warrants(obj["warrants"]) : nil
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
@@ -63,6 +63,8 @@ module Zaig
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def build_shareholders(obj_shareholders)
|
66
|
+
return nil if obj_shareholders.nil?
|
67
|
+
|
66
68
|
shareholders = []
|
67
69
|
|
68
70
|
obj_shareholders.each do |s|
|
@@ -86,6 +88,8 @@ module Zaig
|
|
86
88
|
end
|
87
89
|
|
88
90
|
def build_financial(fin)
|
91
|
+
return nil if fin.nil?
|
92
|
+
|
89
93
|
{
|
90
94
|
amount: fin["amount"],
|
91
95
|
annual_interest_rate: fin["annual_interest_rate"],
|
@@ -97,6 +101,8 @@ module Zaig
|
|
97
101
|
end
|
98
102
|
|
99
103
|
def build_warrants(obj_warrants)
|
104
|
+
return nil if obj_warrants.nil?
|
105
|
+
|
100
106
|
warrants = []
|
101
107
|
|
102
108
|
obj_warrants.each do |w|
|
@@ -112,6 +118,8 @@ module Zaig
|
|
112
118
|
end
|
113
119
|
|
114
120
|
def build_source(obj_source)
|
121
|
+
return nil if obj_source.nil?
|
122
|
+
|
115
123
|
{
|
116
124
|
channel: obj_source["channel"],
|
117
125
|
ip: obj_source["ip"],
|
@@ -120,6 +128,8 @@ module Zaig
|
|
120
128
|
end
|
121
129
|
|
122
130
|
def build_scr_parameters(obj_src)
|
131
|
+
return nil if obj_src.nil?
|
132
|
+
|
123
133
|
{
|
124
134
|
signers: build_signers(obj_src["signers"]),
|
125
135
|
signature_evidence: {
|
@@ -135,6 +145,8 @@ module Zaig
|
|
135
145
|
end
|
136
146
|
|
137
147
|
def build_signers(obj_signers)
|
148
|
+
return nil if obj_signers.nil?
|
149
|
+
|
138
150
|
signers = []
|
139
151
|
obj_signers.each do |s|
|
140
152
|
signers << {
|
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.3"
|
12
12
|
end
|
data/lib/zaig.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "confset"
|
4
3
|
require "cpf_cnpj"
|
5
4
|
require "flash_integration"
|
6
5
|
require "i18n"
|
@@ -48,18 +47,6 @@ module Zaig
|
|
48
47
|
|
49
48
|
# Basic configuration settings
|
50
49
|
class Configuration
|
51
|
-
attr_accessor :access_token, :base_url, :
|
52
|
-
attr_reader :defaults
|
53
|
-
|
54
|
-
def initialize
|
55
|
-
@env = "development"
|
56
|
-
|
57
|
-
load_defaults
|
58
|
-
end
|
59
|
-
|
60
|
-
def load_defaults
|
61
|
-
@defaults = Confset.load_files("lib/config/settings/#{@env}.yml")
|
62
|
-
@base_url = @defaults.api.base_url
|
63
|
-
end
|
50
|
+
attr_accessor :access_token, :base_url, :registration_endpoint
|
64
51
|
end
|
65
52
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.3
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: confset
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: cpf_cnpj
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -295,8 +281,6 @@ extensions: []
|
|
295
281
|
extra_rdoc_files: []
|
296
282
|
files:
|
297
283
|
- Rakefile
|
298
|
-
- lib/config/settings/development.yml
|
299
|
-
- lib/config/settings/production.yml
|
300
284
|
- lib/locales/en.yml
|
301
285
|
- lib/locales/pt-BR.yml
|
302
286
|
- lib/zaig.rb
|