zaig 1.0.7 → 1.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8772408f0511d1fe3a5de65ddf6344af3d32754bdb7ce95252a05cb3e3cb144c
4
- data.tar.gz: d01ca6b7f88430671f09a61a1af872650438113fac5bce59aa74838808b267cc
3
+ metadata.gz: 34c167ec0df18b273efccaa3a917a0295d32d7fc898a3f8787bc7af20616d142
4
+ data.tar.gz: b8825e48c786235fc7168bea2f5d4b43cb551e81b63cc5e5851b857b8b0cc2f6
5
5
  SHA512:
6
- metadata.gz: bacc2f06a07747edfff29022645d937cca069244b7857604bcebb0926578a498a3224c62153e8b5d18d40bc5754ed61dc29701db2bae3cab247db95b73cee06d
7
- data.tar.gz: f1d7438aae92727b67056b38ddea0e39760ecc9ae925883682faed8b5ef4740cbdc0d9fd5b691740087b72b4555b95e0f45c915658ba8e14eb7f0d9450b06bf2
6
+ metadata.gz: f2c1b0f6146ca518641e4021f209ba3c15946fc8d38b4a080eaec20b0fe852a28a50c03f0eebde5dffb7e81c2f06f934f89fa4857b0dca156c4af4c11ab2fd58
7
+ data.tar.gz: a35126e8b604ebba65e084aa44f6805fdcbe999b53d33599a77d28f8d6dfaaa425f52b360b86389c96fa67d01b4e3ae3c430393b7ba427d3c26d78a857f6e7a8
@@ -18,7 +18,7 @@ module Zaig
18
18
  Accept: "application/json"
19
19
  }
20
20
 
21
- return headers if @jwt_secret.nil? || @jwt_secret.empty?
21
+ return headers if @jwt_secret.nil? || @jwt_secret&.empty?
22
22
 
23
23
  headers[:Authorization] = "Bearer #{access_token}"
24
24
  headers
@@ -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.instance)
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", field_name: "resposta_zaig")
52
- error.detail = JSON.parse(res.body, symbolize_names: true)[: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[: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)
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.7"
11
+ VERSION = "1.0.10"
12
12
  end
data/lib/zaig.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "cpf_cnpj"
4
4
  require "flash_integration"
5
5
  require "i18n"
6
- require "singleton"
6
+ require "jwt"
7
7
 
8
8
  require "zaig/base_error"
9
9
  require "zaig/already_exists_error"
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.7
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-20 00:00:00.000000000 Z
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