zaig 1.0.8 → 1.0.11

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: 05cec7da728cfbfdf5457960a2d289e4963d22874f9790e12408eb2498aff1de
4
- data.tar.gz: 1b73d0fe9a384e2bb73dd6af74939117329142fa9bf9aa27eeb28ccca5af2f95
3
+ metadata.gz: '03094fa60fc889bb1771ce1e6ae0daf0e2df220d669fecdd9afac1bcc2de5991'
4
+ data.tar.gz: 61de42ec0c42be9c38469a7f9bec9b32b7cc5257d28cc8b912e0ea6e644ebcd3
5
5
  SHA512:
6
- metadata.gz: 7f5c7152922f7a0823b805ad584986ed2c4b2f86484b5ca1f0c5544960cc15a20cbc48a1c0c299eb7b8e226a09d61eb74b5915a928fc4492876b0d7ca8fe4443
7
- data.tar.gz: fa24fdd51580ef3a9f64bc02eda165e2c928fbc087b8595b5570324657e2509def4a510f84ca3452f0b54e24dd15c58ba44a01a9bd41e0a85e780ec8a88944a0
6
+ metadata.gz: 751ae73d08258541b3d1d98b82f0730d113c80c6c81b26121318a446a9f914457a4cf1b4d0f224e010359fca221255cc5d7d6195716ec2fd77f61e92ac553682
7
+ data.tar.gz: 5547939be36e3dbda4f8a366486f9e1a305875733e362e9e70c4c641dee5e7ed714d39e4e0336abb3191ffab232c8d9a95e3ecc435cbef1bb35dae2da67ddd72
@@ -3,9 +3,10 @@
3
3
  module Zaig
4
4
  # Class to instance a authenticated connection object.
5
5
  class Connection < Flash::Integration::Connection
6
+ JWT_EXP_TIME = DateTime.now.next_day(1).to_time.to_i.freeze
7
+
6
8
  def initialize(request_class: Faraday, base_url: Zaig.configuration.base_url)
7
9
  @jwt_algorithm = Zaig.configuration.jwt_algorithm
8
- @jwt_exp_time = Zaig.configuration.jwt_exp_time
9
10
  @jwt_secret = Zaig.configuration.jwt_secret
10
11
  @jwt_user = Zaig.configuration.jwt_user
11
12
 
@@ -26,7 +27,7 @@ module Zaig
26
27
 
27
28
  private
28
29
  def access_token
29
- JWT.encode({ exp: @jwt_exp_time, user: @jwt_user }, @jwt_secret, @jwt_algorithm)
30
+ JWT.encode({ exp: JWT_EXP_TIME, user: @jwt_user }, @jwt_secret, @jwt_algorithm)
30
31
  end
31
32
  end
32
33
  end
@@ -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
@@ -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
 
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.8"
11
+ VERSION = "1.0.11"
12
12
  end
data/lib/zaig.rb CHANGED
@@ -4,7 +4,6 @@ require "cpf_cnpj"
4
4
  require "flash_integration"
5
5
  require "i18n"
6
6
  require "jwt"
7
- require "singleton"
8
7
 
9
8
  require "zaig/base_error"
10
9
  require "zaig/already_exists_error"
@@ -50,16 +49,12 @@ module Zaig
50
49
  # Basic configuration settings
51
50
  class Configuration
52
51
  attr_accessor :base_url, :jwt_secret, :jwt_user
53
- attr_writer :jwt_algorithm, :jwt_exp_time, :registration_endpoint
52
+ attr_writer :jwt_algorithm, :registration_endpoint
54
53
 
55
54
  def jwt_algorithm
56
55
  @jwt_algorithm ||= "HS256"
57
56
  end
58
57
 
59
- def jwt_exp_time
60
- @jwt_exp_time ||= 1_658_439_475
61
- end
62
-
63
58
  def registration_endpoint
64
59
  @registration_endpoint ||= "zaig/consulta_de_credito"
65
60
  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.8
4
+ version: 1.0.11
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-21 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