incognia_api 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52bbb4d602bec60845df1106450e7d4642f55cc993635fe67abf05bb1e4faf3
4
- data.tar.gz: 88daa93221f7d5901ae3235e7da5175a0a2542e7778543f713687b34d4c49d28
3
+ metadata.gz: 485a9d5fcf16b98a5ca942d1d4fe47e876f25f60a70193d7bcb70110aebd725a
4
+ data.tar.gz: 97a539a4a8a7a7d30ab63e12f6969b34580386fa76e93dee106ffd9a8371f253
5
5
  SHA512:
6
- metadata.gz: ee85936265c871bb6d76a1b10f4c2959d7e2ce9bc3c5df5eba102e5f4a3a1b2b33f35b79636db0b12e79955177dd8733d70e4e5cb8c32a47560f112ac6f3839f
7
- data.tar.gz: a9c0b9a25f6b06931d6bc14e0fabb6d4e068d774e9c526e28bf6a66ac5d125b8c2549bee872f6f8e50d6a4781a3ca79a7338ce11e50784963d891c623fec62f0
6
+ metadata.gz: f282bbcc8499cbc2bcae7ad4aaa151dc785a7c1e86e40ebeabe91de440ba51b28d9de06c2e4db9a9870381d3ba6fc6ebbd4e71e9dfdd61c821b085a18fd6cf2e
7
+ data.tar.gz: bffdaf58ca5335190f1a7b4a11ad1a2e0254f47a75366a60b54f3e6697b58c79f2ba531e49f0195068c768327e205b06016120b38369da35cbf77db1bbbf763f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.2.0] - 2025-09-16
4
+
5
+ - Add support for passing an optional person_id parameter to HTTP request helpers
6
+
3
7
  ## [2.1.0] - 2025-05-09
4
8
 
5
9
  - Add support for passing an optional location parameter to register logins and payments
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incognia_api (2.1.0)
4
+ incognia_api (2.2.0)
5
5
  faraday (~> 1.10)
6
6
  faraday_middleware (~> 1.2)
7
7
 
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 resounces dinamically built from API responses
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 = Incognia::Address.new(line: "West 34th Street, New York City, NY 10001")
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
- external_id = 'some-external-identifier'
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 an date in **RFC 3339** format.
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 an date in **RFC 3339** format.
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
@@ -9,10 +9,11 @@ module Incognia
9
9
  # business layer: uses the Client.instance to build domain objects
10
10
  # raises missing parameters errors
11
11
 
12
- def register_signup(request_token: nil, address: nil, **opts)
12
+ def register_signup(request_token: nil, address: nil, person_id: nil, **opts)
13
13
  params = { request_token: request_token }.compact
14
14
  params.merge!(opts)
15
15
  params.merge!(address.to_hash) if address
16
+ params.merge!(person_id: person_id.to_hash) if person_id
16
17
 
17
18
  response = connection.request(
18
19
  :post,
@@ -23,13 +24,14 @@ module Incognia
23
24
  SignupAssessment.from_hash(response.body) if response.success?
24
25
  end
25
26
 
26
- def register_login(account_id:, request_token: nil, location: nil, **opts)
27
+ def register_login(account_id:, request_token: nil, location: nil, person_id: nil, **opts)
27
28
  params = {
28
29
  type: :login,
29
30
  account_id: account_id,
30
31
  request_token: request_token
31
32
  }.compact
32
33
  params.merge!(location: location.to_hash) if location
34
+ params.merge!(person_id: person_id.to_hash) if person_id
33
35
  params.merge!(opts)
34
36
 
35
37
  response = connection.request(
@@ -41,11 +43,12 @@ module Incognia
41
43
  LoginAssessment.from_hash(response.body) if response.success?
42
44
  end
43
45
 
44
- def register_feedback(event:, occurred_at: nil, expires_at: nil, **ids)
46
+ def register_feedback(event:, occurred_at: nil, expires_at: nil, person_id: nil, **ids)
45
47
  occurred_at = occurred_at.to_datetime.rfc3339 if occurred_at.respond_to? :to_datetime
46
48
  expires_at = expires_at.to_datetime.rfc3339 if expires_at.respond_to? :to_datetime
47
49
 
48
50
  params = { event: event, occurred_at: occurred_at, expires_at: expires_at }.compact
51
+ params.merge!(person_id: person_id.to_hash) if person_id
49
52
  params.merge!(ids)
50
53
 
51
54
  response = connection.request(
@@ -57,13 +60,14 @@ module Incognia
57
60
  response.success?
58
61
  end
59
62
 
60
- def register_payment(account_id:, request_token: nil, location: nil, **opts)
63
+ def register_payment(account_id:, request_token: nil, location: nil, person_id: nil, **opts)
61
64
  params = {
62
65
  type: :payment,
63
66
  account_id: account_id,
64
67
  request_token: request_token
65
68
  }.compact
66
69
  params.merge!(location: location.to_hash) if location
70
+ params.merge!(person_id: person_id.to_hash) if person_id
67
71
  params.merge!(opts)
68
72
 
69
73
  response = connection.request(
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Incognia
4
+ class PersonId
5
+ attr_reader :type, :value
6
+
7
+ def initialize(type:, value:)
8
+ @type = type
9
+ @value = value
10
+ end
11
+
12
+ def to_hash
13
+ { type: type, value: value }
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Incognia
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
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: 2.1.0
4
+ version: 2.2.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-05-09 00:00:00.000000000 Z
11
+ date: 2025-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,7 +46,7 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".github/CODEOWNERS"
49
- - ".github/workflows/codeql.yml"
49
+ - ".github/workflows/codeql.yaml"
50
50
  - ".github/workflows/main.yml"
51
51
  - ".gitignore"
52
52
  - ".rspec"
@@ -66,6 +66,7 @@ files:
66
66
  - lib/incognia_api/configuration.rb
67
67
  - lib/incognia_api/constants/feedback_event.rb
68
68
  - lib/incognia_api/location.rb
69
+ - lib/incognia_api/person_id.rb
69
70
  - lib/incognia_api/resources/api_resource.rb
70
71
  - lib/incognia_api/resources/credentials.rb
71
72
  - lib/incognia_api/resources/login_assessment.rb
File without changes