incognia_api 2.1.0 → 3.0.0
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/CHANGELOG.md +8 -0
- data/Gemfile.lock +13 -30
- data/README.md +55 -7
- data/fixtures/vcr_cassettes/token.yml +2 -2
- data/incognia_api.gemspec +2 -3
- data/lib/incognia_api/api.rb +8 -5
- data/lib/incognia_api/client.rb +3 -6
- data/lib/incognia_api/person_id.rb +16 -0
- data/lib/incognia_api/version.rb +1 -1
- data/lib/incognia_api.rb +1 -0
- metadata +7 -20
- /data/.github/workflows/{codeql.yml → codeql.yaml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 823c5ab4bca2a8fd1d856482906971073d95a1f55e378c6d812da69d205f689e
|
4
|
+
data.tar.gz: 26e4f368b891e14cab04a69b1de02342bf48e2b5f0eea474a1947bf5103fd773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e34fe28af027501b6e4f907d4c9973c930fc86b2ce3ae565fce72979c3a55098a0c3700b91f62d00d7c8ab2d350440e89caf11b0a716c053d6e5f7f89ca2731
|
7
|
+
data.tar.gz: 07ece7a29b0fe8dcb88b1e7df6817d83ab13c42c751bdcb83877912df9f4c94c54d401368c549e0f4cce3e28ffcdfb19a28df5abb27823d9f012ecd6a0f8ec2b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [3.0.0] - 2025-09-22
|
4
|
+
- Update `faraday` dependency to version 2.13.4
|
5
|
+
- Remove `faraday_middleware` dependency
|
6
|
+
|
7
|
+
## [2.2.0] - 2025-09-16
|
8
|
+
|
9
|
+
- Add support for passing an optional person_id parameter to HTTP request helpers
|
10
|
+
|
3
11
|
## [2.1.0] - 2025-05-09
|
4
12
|
|
5
13
|
- Add support for passing an optional location parameter to register logins and payments
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
incognia_api (
|
5
|
-
faraday (~>
|
6
|
-
faraday_middleware (~> 1.2)
|
4
|
+
incognia_api (3.0.0)
|
5
|
+
faraday (~> 2.13)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -14,34 +13,18 @@ GEM
|
|
14
13
|
crack (0.4.5)
|
15
14
|
rexml
|
16
15
|
diff-lcs (1.4.4)
|
17
|
-
faraday (
|
18
|
-
faraday-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
faraday-net_http (~> 1.0)
|
24
|
-
faraday-net_http_persistent (~> 1.0)
|
25
|
-
faraday-patron (~> 1.0)
|
26
|
-
faraday-rack (~> 1.0)
|
27
|
-
faraday-retry (~> 1.0)
|
28
|
-
ruby2_keywords (>= 0.0.4)
|
29
|
-
faraday-em_http (1.0.0)
|
30
|
-
faraday-em_synchrony (1.0.0)
|
31
|
-
faraday-excon (1.1.0)
|
32
|
-
faraday-httpclient (1.0.1)
|
33
|
-
faraday-multipart (1.0.4)
|
34
|
-
multipart-post (~> 2)
|
35
|
-
faraday-net_http (1.0.1)
|
36
|
-
faraday-net_http_persistent (1.2.0)
|
37
|
-
faraday-patron (1.0.0)
|
38
|
-
faraday-rack (1.0.0)
|
39
|
-
faraday-retry (1.0.3)
|
40
|
-
faraday_middleware (1.2.0)
|
41
|
-
faraday (~> 1.0)
|
16
|
+
faraday (2.13.4)
|
17
|
+
faraday-net_http (>= 2.0, < 3.5)
|
18
|
+
json
|
19
|
+
logger
|
20
|
+
faraday-net_http (3.4.1)
|
21
|
+
net-http (>= 0.5.0)
|
42
22
|
hashdiff (1.0.1)
|
23
|
+
json (2.14.0)
|
24
|
+
logger (1.7.0)
|
43
25
|
method_source (1.0.0)
|
44
|
-
|
26
|
+
net-http (0.6.0)
|
27
|
+
uri
|
45
28
|
pry (0.14.2)
|
46
29
|
coderay (~> 1.1)
|
47
30
|
method_source (~> 1.0)
|
@@ -61,8 +44,8 @@ GEM
|
|
61
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
45
|
rspec-support (~> 3.10.0)
|
63
46
|
rspec-support (3.10.2)
|
64
|
-
ruby2_keywords (0.0.5)
|
65
47
|
timecop (0.9.4)
|
48
|
+
uri (1.0.3)
|
66
49
|
webmock (3.14.0)
|
67
50
|
addressable (>= 2.8.0)
|
68
51
|
crack (>= 0.3.2)
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Incognia Ruby library provides easy access to the Incogia API from Ruby
|
|
6
6
|
applications. It includes:
|
7
7
|
|
8
8
|
- Basic Access Token management (with transparent token refresh)
|
9
|
-
- API
|
9
|
+
- API resources dinamically built from API responses
|
10
10
|
|
11
11
|
For more information on how to integrate Incognia APIs, refer to one of the
|
12
12
|
following guides:
|
@@ -69,14 +69,35 @@ assessment = Incognia::Api.register_signup(
|
|
69
69
|
It also supports optional parameters, for example:
|
70
70
|
|
71
71
|
```ruby
|
72
|
-
address
|
72
|
+
# address may include any or all of the following formats: address line, coordinates, or structured address
|
73
|
+
address = Incognia::Address.new(
|
74
|
+
line: "Av. Paulista, 1578 - Bela Vista, São Paulo - SP, 01310-200",
|
75
|
+
coordinates: {lat: -23.589339, lng: -46.659043},
|
76
|
+
structured:
|
77
|
+
{
|
78
|
+
locale: "pt-BR",
|
79
|
+
country_name: "Brasil",
|
80
|
+
country_code: "BR",
|
81
|
+
state: "SP",
|
82
|
+
city: "São Paulo",
|
83
|
+
borough: "",
|
84
|
+
neighborhood: "Bela Vista",
|
85
|
+
street: "Av. Paulista",
|
86
|
+
number: "1578",
|
87
|
+
complements: "Andar 2",
|
88
|
+
postal_code: "01310-200"
|
89
|
+
}
|
90
|
+
)
|
91
|
+
# Person id: either a valid SSN (USA) or CPF (Brazil). Only numerical characters must be provided as value.
|
92
|
+
person_id = Incognia::PersonId.new(type: "cpf", value: "12345678901")
|
73
93
|
request_token = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
|
74
94
|
external_id = "7b02736a-7718-4b83-8982-f68fb6f501fa"
|
75
95
|
|
76
96
|
assessment = Incognia::Api.register_signup(
|
77
97
|
request_token: request_token,
|
78
98
|
address: address,
|
79
|
-
external_id: external_id
|
99
|
+
external_id: external_id,
|
100
|
+
person_id: person_id
|
80
101
|
)
|
81
102
|
|
82
103
|
# => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
|
@@ -102,14 +123,29 @@ assessment = Incognia::Api.register_login(
|
|
102
123
|
It also supports optional parameters, for example:
|
103
124
|
|
104
125
|
```ruby
|
126
|
+
timestamp = Date.parse("2025-04-23T12:12:12-03:00")
|
127
|
+
location = Incognia::Location.new(latitude: -23.589339, longitude: -46.659043, collected_at: timestamp)
|
128
|
+
# These are all also valid timestamps for Location.timestamp
|
129
|
+
timestamp1 = Time.new(2025, 4, 23, 12, 12, 12, "-03:00")
|
130
|
+
timestamp2 = DateTime.parse("2025-04-23T12:12:12-03:00")
|
131
|
+
timestamp3 = "2025-04-23T12:12:12-03:00"
|
132
|
+
timestamp4 = Time.now()
|
133
|
+
|
134
|
+
# Person id: either a valid SSN (USA) or CPF (Brazil). Only numerical characters must be provided as value.
|
135
|
+
person_id = Incognia::PersonId.new(type: "cpf", value: "12345678901")
|
136
|
+
external_id = 'some-external-identifier'
|
137
|
+
|
138
|
+
# Mandatory fields
|
105
139
|
request_token = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
|
106
140
|
account_id = 'account-identifier-123'
|
107
|
-
|
141
|
+
|
108
142
|
|
109
143
|
assessment = Incognia::Api.register_login(
|
110
144
|
request_token: request_token,
|
111
145
|
account_id: account_id,
|
112
146
|
external_id: external_id,
|
147
|
+
person_id: person_id,
|
148
|
+
location: location,
|
113
149
|
eval: false # can be used to register a new login without evaluating it
|
114
150
|
)
|
115
151
|
|
@@ -182,9 +218,17 @@ payment_methods = [
|
|
182
218
|
}
|
183
219
|
]
|
184
220
|
|
221
|
+
location = Incognia::Location.new(latitude: -23.589339, longitude: -46.659043, collected_at: "2025-04-23T12:12:12-03:00")
|
222
|
+
|
223
|
+
# Person id: either a valid SSN (USA) or CPF (Brazil). Only numerical characters must be provided as value.
|
224
|
+
person_id = Incognia::PersonId.new(type: "cpf", value: "12345678901")
|
225
|
+
external_id = 'some-external-identifier'
|
226
|
+
|
185
227
|
assessment = Incognia::Api.register_payment(
|
186
228
|
request_token: 'request-token',
|
187
229
|
account_id: 'account-id',
|
230
|
+
location: location,
|
231
|
+
person_id: person_id,
|
188
232
|
external_id: 'external-id',
|
189
233
|
addresses: addresses,
|
190
234
|
payment_value: payment_value,
|
@@ -198,21 +242,25 @@ assessment = Incognia::Api.register_payment(
|
|
198
242
|
|
199
243
|
This method registers a feedback event for the given identifiers (optional arguments), returning true when success.
|
200
244
|
|
201
|
-
The `occurred_at` argument should be a _Time_, _DateTime_ or
|
245
|
+
The `occurred_at` argument should be a _Time_, _DateTime_ or a date in **RFC 3339** format.
|
202
246
|
|
203
|
-
The `expires_at` argument should be a _Time_, _DateTime_ or
|
247
|
+
The `expires_at` argument should be a _Time_, _DateTime_ or a date in **RFC 3339** format.
|
204
248
|
|
205
249
|
|
206
250
|
```ruby
|
207
251
|
request_token = 'request-token'
|
208
252
|
account_id = 'account-id'
|
209
253
|
occurred_at = DateTime.parse('2024-07-22T15:20:00Z')
|
254
|
+
# person id: optional
|
255
|
+
person_id = Incognia::PersonId.new(type: "cpf", value: "12345678901")
|
256
|
+
|
210
257
|
|
211
258
|
success = Incognia::Api.register_feedback(
|
212
259
|
event: Incognia::Constants::FeedbackEvent::ACCOUNT_TAKEOVER,
|
213
260
|
occurred_at: occurred_at,
|
214
261
|
request_token: request_token,
|
215
|
-
account_id: account_id
|
262
|
+
account_id: account_id,
|
263
|
+
person_id: person_id
|
216
264
|
)
|
217
265
|
|
218
266
|
# => true
|
@@ -8,7 +8,7 @@ http_interactions:
|
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday
|
11
|
+
- Faraday v2.13.4
|
12
12
|
Authorization:
|
13
13
|
- Basic R1BXSzFMQ1paSW8xRkxPQ0NuTExNcU44UWkxSHYzazQ6RUxHOV8yazU5T0hkMUdiVXhIaGRTdGtqZUI3TXlQZ21vRjhlR2YxM0xBMU1scmZRZ1Q1bkhFMmFIaVNobVc0WA==
|
14
14
|
Content-Type:
|
@@ -58,7 +58,7 @@ http_interactions:
|
|
58
58
|
string: '{"installation_id":"xyz"}'
|
59
59
|
headers:
|
60
60
|
User-Agent:
|
61
|
-
- Faraday
|
61
|
+
- Faraday v2.13.4
|
62
62
|
Authorization:
|
63
63
|
- Bearer access_token
|
64
64
|
Content-Type:
|
data/incognia_api.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "Official Ruby lib for communicating with Incognia API"
|
12
12
|
spec.description = "Official Ruby lib for communicating with Incognia API"
|
13
13
|
spec.homepage = "https://github.com/inloco/incognia-ruby"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/inloco/incognia-ruby"
|
@@ -28,8 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
# Uncomment to register a new dependency of your gem
|
30
30
|
# spec.add_dependency "example-gem", "~> 1.0"
|
31
|
-
spec.add_dependency('faraday', '~>
|
32
|
-
spec.add_dependency('faraday_middleware', '~> 1.2')
|
31
|
+
spec.add_dependency('faraday', '~> 2.13')
|
33
32
|
|
34
33
|
# For more information and examples about making a new gem, checkout our
|
35
34
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/incognia_api/api.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "faraday"
|
2
2
|
require "json"
|
3
3
|
require "logger"
|
4
|
-
require 'faraday_middleware'
|
5
4
|
|
6
5
|
module Incognia
|
7
6
|
class Api
|
@@ -9,10 +8,11 @@ module Incognia
|
|
9
8
|
# business layer: uses the Client.instance to build domain objects
|
10
9
|
# raises missing parameters errors
|
11
10
|
|
12
|
-
def register_signup(request_token: nil, address: nil, **opts)
|
11
|
+
def register_signup(request_token: nil, address: nil, person_id: nil, **opts)
|
13
12
|
params = { request_token: request_token }.compact
|
14
13
|
params.merge!(opts)
|
15
14
|
params.merge!(address.to_hash) if address
|
15
|
+
params.merge!(person_id: person_id.to_hash) if person_id
|
16
16
|
|
17
17
|
response = connection.request(
|
18
18
|
:post,
|
@@ -23,13 +23,14 @@ module Incognia
|
|
23
23
|
SignupAssessment.from_hash(response.body) if response.success?
|
24
24
|
end
|
25
25
|
|
26
|
-
def register_login(account_id:, request_token: nil, location: nil, **opts)
|
26
|
+
def register_login(account_id:, request_token: nil, location: nil, person_id: nil, **opts)
|
27
27
|
params = {
|
28
28
|
type: :login,
|
29
29
|
account_id: account_id,
|
30
30
|
request_token: request_token
|
31
31
|
}.compact
|
32
32
|
params.merge!(location: location.to_hash) if location
|
33
|
+
params.merge!(person_id: person_id.to_hash) if person_id
|
33
34
|
params.merge!(opts)
|
34
35
|
|
35
36
|
response = connection.request(
|
@@ -41,11 +42,12 @@ module Incognia
|
|
41
42
|
LoginAssessment.from_hash(response.body) if response.success?
|
42
43
|
end
|
43
44
|
|
44
|
-
def register_feedback(event:, occurred_at: nil, expires_at: nil, **ids)
|
45
|
+
def register_feedback(event:, occurred_at: nil, expires_at: nil, person_id: nil, **ids)
|
45
46
|
occurred_at = occurred_at.to_datetime.rfc3339 if occurred_at.respond_to? :to_datetime
|
46
47
|
expires_at = expires_at.to_datetime.rfc3339 if expires_at.respond_to? :to_datetime
|
47
48
|
|
48
49
|
params = { event: event, occurred_at: occurred_at, expires_at: expires_at }.compact
|
50
|
+
params.merge!(person_id: person_id.to_hash) if person_id
|
49
51
|
params.merge!(ids)
|
50
52
|
|
51
53
|
response = connection.request(
|
@@ -57,13 +59,14 @@ module Incognia
|
|
57
59
|
response.success?
|
58
60
|
end
|
59
61
|
|
60
|
-
def register_payment(account_id:, request_token: nil, location: nil, **opts)
|
62
|
+
def register_payment(account_id:, request_token: nil, location: nil, person_id: nil, **opts)
|
61
63
|
params = {
|
62
64
|
type: :payment,
|
63
65
|
account_id: account_id,
|
64
66
|
request_token: request_token
|
65
67
|
}.compact
|
66
68
|
params.merge!(location: location.to_hash) if location
|
69
|
+
params.merge!(person_id: person_id.to_hash) if person_id
|
67
70
|
params.merge!(opts)
|
68
71
|
|
69
72
|
response = connection.request(
|
data/lib/incognia_api/client.rb
CHANGED
@@ -14,9 +14,7 @@ module Incognia
|
|
14
14
|
json_data = JSON.generate(data) if data
|
15
15
|
|
16
16
|
connection.send(method, endpoint, json_data, headers) do |r|
|
17
|
-
r.headers[Faraday::Request::Authorization::KEY] ||=
|
18
|
-
.lookup_middleware(:authorization)
|
19
|
-
.header(:Bearer, credentials.access_token)
|
17
|
+
r.headers[Faraday::Request::Authorization::KEY] ||= "Bearer #{credentials.access_token}"
|
20
18
|
end
|
21
19
|
rescue Faraday::ClientError, Faraday::ServerError => e
|
22
20
|
raise APIError.new(e.to_s, e.response)
|
@@ -50,9 +48,8 @@ module Incognia
|
|
50
48
|
protected
|
51
49
|
|
52
50
|
def request_credentials
|
53
|
-
basic_auth = Faraday::
|
54
|
-
.
|
55
|
-
.header(Incognia.config.client_id, Incognia.config.client_secret)
|
51
|
+
basic_auth = Faraday::Utils
|
52
|
+
.basic_header_from(Incognia.config.client_id, Incognia.config.client_secret)
|
56
53
|
|
57
54
|
response = connection.send(:post, 'v2/token') do |r|
|
58
55
|
r.headers[Faraday::Request::Authorization::KEY] = basic_auth
|
data/lib/incognia_api/version.rb
CHANGED
data/lib/incognia_api.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "incognia_api/util"
|
|
7
7
|
require_relative "incognia_api/address"
|
8
8
|
require_relative "incognia_api/api"
|
9
9
|
require_relative "incognia_api/location"
|
10
|
+
require_relative "incognia_api/person_id"
|
10
11
|
|
11
12
|
require_relative "incognia_api/resources/api_resource"
|
12
13
|
require_relative "incognia_api/resources/signup_assessment"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incognia_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.13'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: faraday_middleware
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.2'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.2'
|
26
|
+
version: '2.13'
|
41
27
|
description: Official Ruby lib for communicating with Incognia API
|
42
28
|
email:
|
43
29
|
- guiocavalcanti@gmail.com
|
@@ -46,7 +32,7 @@ extensions: []
|
|
46
32
|
extra_rdoc_files: []
|
47
33
|
files:
|
48
34
|
- ".github/CODEOWNERS"
|
49
|
-
- ".github/workflows/codeql.
|
35
|
+
- ".github/workflows/codeql.yaml"
|
50
36
|
- ".github/workflows/main.yml"
|
51
37
|
- ".gitignore"
|
52
38
|
- ".rspec"
|
@@ -66,6 +52,7 @@ files:
|
|
66
52
|
- lib/incognia_api/configuration.rb
|
67
53
|
- lib/incognia_api/constants/feedback_event.rb
|
68
54
|
- lib/incognia_api/location.rb
|
55
|
+
- lib/incognia_api/person_id.rb
|
69
56
|
- lib/incognia_api/resources/api_resource.rb
|
70
57
|
- lib/incognia_api/resources/credentials.rb
|
71
58
|
- lib/incognia_api/resources/login_assessment.rb
|
@@ -87,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
74
|
requirements:
|
88
75
|
- - ">="
|
89
76
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
77
|
+
version: 3.0.0
|
91
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
79
|
requirements:
|
93
80
|
- - ">="
|
File without changes
|