zaig 1.0.6 → 1.0.7
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/connection.rb +17 -5
- data/lib/zaig/registration.rb +1 -3
- data/lib/zaig/version.rb +1 -1
- data/lib/zaig.rb +14 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8772408f0511d1fe3a5de65ddf6344af3d32754bdb7ce95252a05cb3e3cb144c
|
4
|
+
data.tar.gz: d01ca6b7f88430671f09a61a1af872650438113fac5bce59aa74838808b267cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bacc2f06a07747edfff29022645d937cca069244b7857604bcebb0926578a498a3224c62153e8b5d18d40bc5754ed61dc29701db2bae3cab247db95b73cee06d
|
7
|
+
data.tar.gz: f1d7438aae92727b67056b38ddea0e39760ecc9ae925883682faed8b5ef4740cbdc0d9fd5b691740087b72b4555b95e0f45c915658ba8e14eb7f0d9450b06bf2
|
data/lib/zaig/connection.rb
CHANGED
@@ -3,18 +3,30 @@
|
|
3
3
|
module Zaig
|
4
4
|
# Class to instance a authenticated connection object.
|
5
5
|
class Connection < Flash::Integration::Connection
|
6
|
-
def initialize(request_class: Faraday, base_url: Zaig.configuration.base_url
|
7
|
-
@
|
6
|
+
def initialize(request_class: Faraday, base_url: Zaig.configuration.base_url)
|
7
|
+
@jwt_algorithm = Zaig.configuration.jwt_algorithm
|
8
|
+
@jwt_exp_time = Zaig.configuration.jwt_exp_time
|
9
|
+
@jwt_secret = Zaig.configuration.jwt_secret
|
10
|
+
@jwt_user = Zaig.configuration.jwt_user
|
8
11
|
|
9
12
|
super(request_class: request_class, base_url: base_url)
|
10
13
|
end
|
11
14
|
|
12
15
|
def default_headers
|
13
|
-
{
|
16
|
+
headers = {
|
14
17
|
"Content-Type": "application/json",
|
15
|
-
Accept: "application/json"
|
16
|
-
"x-api-key": @access_token
|
18
|
+
Accept: "application/json"
|
17
19
|
}
|
20
|
+
|
21
|
+
return headers if @jwt_secret.nil? || @jwt_secret.empty?
|
22
|
+
|
23
|
+
headers[:Authorization] = "Bearer #{access_token}"
|
24
|
+
headers
|
18
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def access_token
|
29
|
+
JWT.encode({ exp: @jwt_exp_time, user: @jwt_user }, @jwt_secret, @jwt_algorithm)
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
data/lib/zaig/registration.rb
CHANGED
@@ -17,9 +17,7 @@ module Zaig
|
|
17
17
|
def call(obj)
|
18
18
|
payload = @registration_payload.call(obj)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
res = @connection.post(url: (req_endpoint.nil? ? ENDPOINT : req_endpoint), body: payload.to_json)
|
20
|
+
res = @connection.post(url: Zaig.configuration.registration_endpoint, body: payload.to_json)
|
23
21
|
|
24
22
|
verify_response(res)
|
25
23
|
|
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.7"
|
12
12
|
end
|
data/lib/zaig.rb
CHANGED
@@ -48,6 +48,19 @@ module Zaig
|
|
48
48
|
|
49
49
|
# Basic configuration settings
|
50
50
|
class Configuration
|
51
|
-
attr_accessor :
|
51
|
+
attr_accessor :base_url, :jwt_secret, :jwt_user
|
52
|
+
attr_writer :jwt_algorithm, :jwt_exp_time, :registration_endpoint
|
53
|
+
|
54
|
+
def jwt_algorithm
|
55
|
+
@jwt_algorithm ||= "HS256"
|
56
|
+
end
|
57
|
+
|
58
|
+
def jwt_exp_time
|
59
|
+
@jwt_exp_time ||= 1_658_439_475
|
60
|
+
end
|
61
|
+
|
62
|
+
def registration_endpoint
|
63
|
+
@registration_endpoint ||= "zaig/consulta_de_credito"
|
64
|
+
end
|
52
65
|
end
|
53
66
|
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.7
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cpf_cnpj
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jwt
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: singleton
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|