incognia_api 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8091ced0819f517cbe35df392b7f51d7943403f0b6053e97226c5dcb91cf7f5d
4
- data.tar.gz: 07732b958841e661ab36548eabc14d4f55895fec5997f40b2e7f4c654d746eac
3
+ metadata.gz: d20f61a585d3f2a6f3ae499a5a32ce1162ce812d6450eaaa3ed2c3107caeff26
4
+ data.tar.gz: f48d53ed2d2bc99face81e094a0193f8a5e5cb0752b12abaaf1020ae3ca47d4f
5
5
  SHA512:
6
- metadata.gz: bd76587fcc7ca3edb6cd011cd8df4d8546d60deaf7026cd2de4241ffccfdafbf288c425627cd437385439ea675269e26e84178233444db02def82c2df2871ee1
7
- data.tar.gz: 6a65cf592482f88de479b5c60233f592e3bfc1ccfe5982e2fb3f37d56285b76d1f3dda133737c03ae771476192708b117632d8813fe3e08f2dd2647883de71c8
6
+ metadata.gz: a686efb7675e67313ea627bc22898d37027e07dd7742153ba525e818f36190be57f1a72848f1149d9826b198d419ac48f550f3e22deb5fb5d1801bc345784dca
7
+ data.tar.gz: 304ee383de088469fc85f5fdb873aeb8650be7c04b0b58c4c6fe37e7f32ae3bf067bfa4726a28f813edc59df3ea7520263478cf08ba927257c3cc4268b351948
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @guiocavalcanti
1
+ * @guiocavalcanti @julianalucena @ottony
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2022-05-06
4
+
5
+ - Allow registering feedbacks
6
+ - Allow registering logins
7
+
3
8
  ## [0.2.0] - 2022-05-06
4
9
 
5
10
  - Allow registering signups without address
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incognia_api (0.2.0)
4
+ incognia_api (0.3.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
data/README.md CHANGED
@@ -75,6 +75,74 @@ assessment = api.get_signup_assessment(signup_id: "95a9fc56-f65e-436b-a87f-a1338
75
75
 
76
76
  ```
77
77
 
78
+ ### Registering a Login
79
+
80
+ This method registers a new login for the given installation and account, returning a login assessment, containing the risk assessment and supporting evidence:
81
+
82
+ ```ruby
83
+ installation_id = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
84
+ account_id = 'account-identifier-123'
85
+
86
+ assessment = api.register_login(
87
+ installation_id: installation_id,
88
+ account_id: account_id,
89
+ )
90
+
91
+ # => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
92
+
93
+ ```
94
+
95
+ It also supports optional parameters, for example:
96
+
97
+ ```ruby
98
+ installation_id = "WlMksW+jh5GPhqWBorsV8yDihoSHHpmt+DpjJ7eYxpHhuO/5tuHTuA..."
99
+ account_id = 'account-identifier-123'
100
+ external_id = 'some-external-identifier'
101
+
102
+ assessment = api.register_login(
103
+ installation_id: installation_id,
104
+ account_id: account_id,
105
+ external_id: external_id,
106
+ eval: false # can be used to register a new login without evaluating it
107
+ )
108
+
109
+ # => #<OpenStruct id="...", device_id="...", risk_assessment="..", evidence=...>
110
+ ```
111
+
112
+ ### Registering a Feedback
113
+
114
+ This method registers a feedback event for the given identifiers (optional arguments), returning true when success.
115
+
116
+ The `timestamp` argument should be a _Time_, _DateTime_ or an _Integer_ being the timestamp in milliseconds:
117
+
118
+ ```ruby
119
+ account_id = "cdb2cfbb-8ad8-4668-b276-5fff9bbfdc96"
120
+ timestamp = DateTime.parse('2022-06-20 23:29:00 UTC-3')
121
+
122
+ success = api.register_feedback(
123
+ event: Incognia::Constants::FeedbackEvent::IDENTITY_FRAUD,
124
+ timestamp: timestamp,
125
+ account_id: account_id
126
+ )
127
+
128
+ # => true
129
+ ```
130
+
131
+ For custom fraud, set the value of `event` with the corresponding code:
132
+
133
+ ```ruby
134
+ success = api.register_feedback(
135
+ event: 'custom_fraud_name'
136
+ timestamp: timestamp,
137
+ account_id: account_id,
138
+ installation_id: installation_id
139
+ )
140
+
141
+ # => true
142
+ ```
143
+
144
+ Check the [documentation](https://developer.incognia.com) to see possible identifiers for each event type.
145
+
78
146
  ## Exception handling
79
147
 
80
148
  Every method call can throw `APIError` and `APIAuthenticationError`.
data/lib/incognia/api.rb CHANGED
@@ -36,6 +36,37 @@ module Incognia
36
36
 
37
37
  SignupAssessment.from_hash(response.body) if response.success?
38
38
  end
39
- end
40
39
 
40
+ def register_login(installation_id:, account_id:, **opts)
41
+ params = {
42
+ type: :login,
43
+ installation_id: installation_id,
44
+ account_id: account_id,
45
+ }
46
+ params.merge!(opts)
47
+
48
+ response = connection.request(
49
+ :post,
50
+ 'v2/authentication/transactions',
51
+ params
52
+ )
53
+
54
+ LoginAssessment.from_hash(response.body) if response.success?
55
+ end
56
+
57
+ def register_feedback(event: , timestamp: nil, **ids)
58
+ timestamp = timestamp.strftime('%s%L') if timestamp.respond_to? :strftime
59
+
60
+ params = { event: event, timestamp: timestamp&.to_i }.compact
61
+ params.merge!(ids)
62
+
63
+ response = connection.request(
64
+ :post,
65
+ '/api/v2/feedbacks',
66
+ params
67
+ )
68
+
69
+ response.success?
70
+ end
71
+ end
41
72
  end
@@ -0,0 +1,33 @@
1
+ module Incognia
2
+ module Constants
3
+ module FeedbackEvent
4
+ ACCOUNT_TAKEOVER = 'account_takeover'.freeze
5
+ CHALLENGE_FAILED = 'challenge_failed'.freeze
6
+ CHALLENGE_PASSED = 'challenge_passed'.freeze
7
+ CHARGEBACK = 'chargeback'.freeze
8
+ CHARGEBACK_NOTIFICATION = 'chargeback_notification'.freeze
9
+ CUSTOM_CHURN_DEBT_20D = 'custom_churn_debt_20d'.freeze
10
+ IDENTITY_FRAUD = 'identity_fraud'.freeze
11
+ MPOS_FRAUD = 'mpos_fraud'.freeze
12
+ PASSWORD_CHANGE_FAILED = 'password_change_failed'.freeze
13
+ PASSWORD_CHANGED_SUCCESSFULLY = 'password_changed_successfully'.freeze
14
+ PROMOTION_ABUSE = 'promotion_abuse'.freeze
15
+ VERIFIED = 'verified'.freeze
16
+
17
+ SIGNUP_ACCEPTED = 'signup_accepted'.freeze
18
+ SIGNUP_DECLINED = 'signup_declined'.freeze
19
+
20
+ LOGIN_ACCEPTED = 'login_accepted'.freeze
21
+ LOGIN_DECLINED = 'login_declined'.freeze
22
+
23
+ PAYMENT_ACCEPTED = 'payment_accepted'.freeze
24
+ PAYMENT_ACCEPTED_BY_CONTROL_GROUP = 'payment_accepted_by_control_group'.freeze
25
+ PAYMENT_ACCEPTED_BY_THIRD_PARTY = 'payment_accepted_by_third_party'.freeze
26
+ PAYMENT_DECLINED = 'payment_declined'.freeze
27
+ PAYMENT_DECLINED_BY_ACQUIRER = 'payment_declined_by_acquirer'.freeze
28
+ PAYMENT_DECLINED_BY_BUSINESS = 'payment_declined_by_business'.freeze
29
+ PAYMENT_DECLINED_BY_MANUAL_REVIEW = 'payment_declined_by_manual_review'.freeze
30
+ PAYMENT_DECLINED_BY_RISK_ANALYSIS = 'payment_declined_by_risk_analysis'.freeze
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "api_resource"
2
+
3
+ module Incognia
4
+ class LoginAssessment < APIResource; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Incognia
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/incognia.rb CHANGED
@@ -8,8 +8,11 @@ require_relative "incognia/api"
8
8
 
9
9
  require_relative "incognia/resources/api_resource"
10
10
  require_relative "incognia/resources/signup_assessment"
11
+ require_relative "incognia/resources/login_assessment"
11
12
  require_relative "incognia/resources/credentials"
12
13
 
14
+ require_relative "incognia/constants/feedback_event"
15
+
13
16
  module Incognia
14
17
  class APIError < StandardError
15
18
  attr_reader :message, :errors, :status
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: 0.2.0
4
+ version: 0.3.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: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -62,8 +62,10 @@ files:
62
62
  - lib/incognia/address.rb
63
63
  - lib/incognia/api.rb
64
64
  - lib/incognia/client.rb
65
+ - lib/incognia/constants/feedback_event.rb
65
66
  - lib/incognia/resources/api_resource.rb
66
67
  - lib/incognia/resources/credentials.rb
68
+ - lib/incognia/resources/login_assessment.rb
67
69
  - lib/incognia/resources/signup_assessment.rb
68
70
  - lib/incognia/util.rb
69
71
  - lib/incognia/version.rb
@@ -88,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  - !ruby/object:Gem::Version
89
91
  version: '0'
90
92
  requirements: []
91
- rubygems_version: 3.1.6
93
+ rubygems_version: 3.2.3
92
94
  signing_key:
93
95
  specification_version: 4
94
96
  summary: Official Ruby lib for communicating with Incognia API