minfraud 1.0.4 → 2.4.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 +5 -5
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/release.yml +28 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +90 -0
- data/CHANGELOG.md +197 -4
- data/CODE_OF_CONDUCT.md +4 -4
- data/Gemfile +2 -2
- data/LICENSE.txt +2 -1
- data/README.dev.md +4 -0
- data/README.md +255 -58
- data/Rakefile +9 -3
- data/bin/console +4 -3
- data/dev-bin/release.sh +59 -0
- data/lib/minfraud/assessments.rb +127 -53
- data/lib/minfraud/components/account.rb +31 -9
- data/lib/minfraud/components/addressable.rb +73 -26
- data/lib/minfraud/components/base.rb +26 -14
- data/lib/minfraud/components/billing.rb +5 -0
- data/lib/minfraud/components/credit_card.rb +117 -29
- data/lib/minfraud/components/custom_inputs.rb +25 -0
- data/lib/minfraud/components/device.rb +51 -10
- data/lib/minfraud/components/email.rb +120 -9
- data/lib/minfraud/components/event.rb +60 -13
- data/lib/minfraud/components/order.rb +59 -22
- data/lib/minfraud/components/payment.rb +192 -22
- data/lib/minfraud/components/report/transaction.rb +80 -0
- data/lib/minfraud/components/shipping.rb +15 -6
- data/lib/minfraud/components/shopping_cart.rb +19 -12
- data/lib/minfraud/components/shopping_cart_item.rb +42 -13
- data/lib/minfraud/enum.rb +22 -8
- data/lib/minfraud/error_handler.rb +45 -18
- data/lib/minfraud/errors.rb +22 -2
- data/lib/minfraud/http_service/response.rb +61 -17
- data/lib/minfraud/model/abstract.rb +20 -0
- data/lib/minfraud/model/address.rb +52 -0
- data/lib/minfraud/model/billing_address.rb +11 -0
- data/lib/minfraud/model/credit_card.rb +75 -0
- data/lib/minfraud/model/device.rb +51 -0
- data/lib/minfraud/model/disposition.rb +42 -0
- data/lib/minfraud/model/email.rb +54 -0
- data/lib/minfraud/model/email_domain.rb +24 -0
- data/lib/minfraud/model/error.rb +28 -0
- data/lib/minfraud/model/factors.rb +24 -0
- data/lib/minfraud/model/geoip2_location.rb +25 -0
- data/lib/minfraud/model/insights.rb +68 -0
- data/lib/minfraud/model/ip_address.rb +58 -0
- data/lib/minfraud/model/ip_risk_reason.rb +48 -0
- data/lib/minfraud/model/issuer.rb +49 -0
- data/lib/minfraud/model/score.rb +76 -0
- data/lib/minfraud/model/score_ip_address.rb +23 -0
- data/lib/minfraud/model/shipping_address.rb +30 -0
- data/lib/minfraud/model/subscores.rb +156 -0
- data/lib/minfraud/model/warning.rb +63 -0
- data/lib/minfraud/report.rb +66 -0
- data/lib/minfraud/resolver.rb +25 -16
- data/lib/minfraud/validates.rb +187 -0
- data/lib/minfraud/version.rb +4 -1
- data/lib/minfraud.rb +55 -16
- data/minfraud.gemspec +27 -18
- metadata +107 -36
- data/.travis.yml +0 -5
- data/lib/minfraud/http_service/request.rb +0 -37
- data/lib/minfraud/http_service.rb +0 -31
@@ -1,22 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Account corresponds to the account object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--account
|
3
8
|
class Account < Base
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
9
|
+
include Minfraud::Validates
|
10
|
+
|
11
|
+
# A unique user ID associated with the end-user in your system. If your
|
12
|
+
# system allows the login name for the account to be changed, this should
|
13
|
+
# not be the login name for the account, but rather should be an internal
|
14
|
+
# ID that does not change. This is not your MaxMind account ID. No
|
15
|
+
# specific format is required.
|
16
|
+
#
|
17
|
+
# @return [String, nil]
|
8
18
|
attr_accessor :user_id
|
9
19
|
|
10
|
-
#
|
11
|
-
#
|
20
|
+
# An MD5 hash as a hexadecimal string of the username or login name
|
21
|
+
# associated with the account.
|
22
|
+
#
|
23
|
+
# @return [String, nil]
|
12
24
|
attr_accessor :username_md5
|
13
25
|
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @return [Minfraud::Components::Account] an Account instance
|
26
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
27
|
+
# correspond to one of the available attributes.
|
17
28
|
def initialize(params = {})
|
18
29
|
@user_id = params[:user_id]
|
19
30
|
@username_md5 = params[:username_md5]
|
31
|
+
|
32
|
+
validate
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def validate
|
38
|
+
return if !Minfraud.enable_validation
|
39
|
+
|
40
|
+
validate_string('user_id', 255, @user_id)
|
41
|
+
validate_md5('username_md5', @username_md5)
|
20
42
|
end
|
21
43
|
end
|
22
44
|
end
|
@@ -1,54 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# This is a parent class for the Billing and Shipping components.
|
3
6
|
class Addressable < Base
|
4
|
-
|
5
|
-
|
7
|
+
include Minfraud::Validates
|
8
|
+
|
9
|
+
# The first name of the end user as provided in their billing / shipping
|
10
|
+
# information.
|
11
|
+
#
|
12
|
+
# @return [String, nil]
|
6
13
|
attr_accessor :first_name
|
7
14
|
|
8
|
-
#
|
9
|
-
#
|
15
|
+
# The last name of the end user as provided in their billing / shipping
|
16
|
+
# information.
|
17
|
+
#
|
18
|
+
# @return [String, nil]
|
10
19
|
attr_accessor :last_name
|
11
20
|
|
12
|
-
#
|
13
|
-
#
|
21
|
+
# The company of the end user as provided in their billing / shipping
|
22
|
+
# information.
|
23
|
+
#
|
24
|
+
# @return [String, nil]
|
14
25
|
attr_accessor :company
|
15
26
|
|
16
|
-
#
|
17
|
-
#
|
27
|
+
# The first line of the user's billing / shipping address.
|
28
|
+
#
|
29
|
+
# @return [String, nil]
|
18
30
|
attr_accessor :address
|
19
31
|
|
20
|
-
#
|
21
|
-
#
|
32
|
+
# The second line of the user's billing / shipping address.
|
33
|
+
#
|
34
|
+
# @return [String, nil]
|
22
35
|
attr_accessor :address_2
|
23
36
|
|
24
|
-
#
|
25
|
-
#
|
37
|
+
# The city of the user's billing / shipping address.
|
38
|
+
#
|
39
|
+
# @return [String, nil]
|
26
40
|
attr_accessor :city
|
27
41
|
|
28
|
-
#
|
29
|
-
#
|
42
|
+
# The ISO 3166-2 subdivision code for the user's billing / shipping
|
43
|
+
# address.
|
44
|
+
#
|
45
|
+
# @see https://en.wikipedia.org/wiki/ISO_3166-2
|
46
|
+
#
|
47
|
+
# @return [String, nil]
|
30
48
|
attr_accessor :region
|
31
49
|
|
32
|
-
#
|
33
|
-
#
|
50
|
+
# The two character ISO 3166-1 alpha-2 country code of the user's billing
|
51
|
+
# / shipping address.
|
52
|
+
#
|
53
|
+
# @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
54
|
+
#
|
55
|
+
# @return [String, nil]
|
34
56
|
attr_accessor :country
|
35
57
|
|
36
|
-
#
|
37
|
-
#
|
58
|
+
# The postal code of the user's billing / shipping address.
|
59
|
+
#
|
60
|
+
# @return [String, nil]
|
38
61
|
attr_accessor :postal
|
39
62
|
|
40
|
-
#
|
41
|
-
#
|
63
|
+
# The phone number without the country code for the user's billing /
|
64
|
+
# shipping address. Punctuation characters will be stripped. After
|
65
|
+
# stripping punctuation characters, the number must contain only digits.
|
66
|
+
#
|
67
|
+
# @return [String, nil]
|
42
68
|
attr_accessor :phone_number
|
43
69
|
|
44
|
-
#
|
45
|
-
#
|
70
|
+
# The country code for the phone number associated with the user's
|
71
|
+
# billing / shipping address. If you provide this information then you
|
72
|
+
# must provide at least one digit.
|
73
|
+
#
|
74
|
+
# @return [String, nil]
|
46
75
|
attr_accessor :phone_country_code
|
47
76
|
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# @param [Hash] params hash of parameters
|
51
|
-
# @return [Minfraud::Components::Addressable] an Addressable instance
|
77
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
78
|
+
# correspond to one of the available attributes.
|
52
79
|
def initialize(params = {})
|
53
80
|
@first_name = params[:first_name]
|
54
81
|
@last_name = params[:last_name]
|
@@ -61,6 +88,26 @@ module Minfraud
|
|
61
88
|
@postal = params[:postal]
|
62
89
|
@phone_number = params[:phone_number]
|
63
90
|
@phone_country_code = params[:phone_country_code]
|
91
|
+
|
92
|
+
validate
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def validate
|
98
|
+
return if !Minfraud.enable_validation
|
99
|
+
|
100
|
+
validate_string('first_name', 255, @first_name)
|
101
|
+
validate_string('last_name', 255, @last_name)
|
102
|
+
validate_string('company', 255, @company)
|
103
|
+
validate_string('address', 255, @address)
|
104
|
+
validate_string('address_2', 255, @address_2)
|
105
|
+
validate_string('city', 255, @city)
|
106
|
+
validate_subdivision_code('region', @region)
|
107
|
+
validate_country_code('country', @country)
|
108
|
+
validate_string('postal', 255, @postal)
|
109
|
+
validate_string('phone_number', 255, @phone_number)
|
110
|
+
validate_telephone_country_code('phone_country_code', @phone_country_code)
|
64
111
|
end
|
65
112
|
end
|
66
113
|
end
|
@@ -1,35 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
3
|
-
#
|
4
|
-
#
|
5
|
+
# This is a parent class for all components. It defines a method which is
|
6
|
+
# used for basic JSON representation of the component objects.
|
5
7
|
class Base
|
6
|
-
#
|
7
|
-
|
8
|
-
|
8
|
+
# A JSON representation of component attributes.
|
9
|
+
#
|
10
|
+
# @return [Hash]
|
11
|
+
def to_json(*_args)
|
12
|
+
instance_variables.reduce({}) { |mem, e| populate!(mem, e) }
|
9
13
|
end
|
10
14
|
|
11
15
|
private
|
12
16
|
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @
|
17
|
+
# Create a hash containing a JSON representation of instance variable
|
18
|
+
# name and its value.
|
19
|
+
#
|
20
|
+
# @param hash [Hash] An accumulator.
|
21
|
+
#
|
22
|
+
# @param v_sym [Symbol] An instance variable symbol.
|
23
|
+
#
|
24
|
+
# @return [Hash]
|
17
25
|
def populate!(hash, v_sym)
|
18
|
-
return hash unless value = instance_variable_get(v_sym)
|
26
|
+
return hash unless (value = instance_variable_get(v_sym))
|
19
27
|
|
20
28
|
key = v_sym.to_s.gsub(/@/, '')
|
21
29
|
hash.merge!(key => represent(key, value))
|
22
30
|
end
|
23
31
|
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# @
|
32
|
+
# Return the value according to the request format.
|
33
|
+
#
|
34
|
+
# @param key [Symbol] An instance variable symbol.
|
35
|
+
#
|
36
|
+
# @param value [Object] An instance variable value.
|
37
|
+
#
|
38
|
+
# @return [Object]
|
27
39
|
def represent(key, value)
|
28
40
|
BOOLS.include?(key) ? value : value.to_s
|
29
41
|
end
|
30
42
|
|
31
43
|
# Keys that have to remain boolean
|
32
|
-
BOOLS = %w
|
44
|
+
BOOLS = %w[was_authorized is_gift has_gift_message].freeze
|
33
45
|
end
|
34
46
|
end
|
35
47
|
end
|
@@ -1,5 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Billing corresponds to the billing object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--billing
|
3
8
|
class Billing < Addressable; end
|
4
9
|
end
|
5
10
|
end
|
@@ -1,51 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# CreditCard corresponds to the credit_card object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--credit-card
|
3
8
|
class CreditCard < Base
|
4
|
-
|
5
|
-
|
6
|
-
#
|
9
|
+
include Minfraud::Validates
|
10
|
+
|
11
|
+
# The issuer ID number for the credit card. This is the first 6 or 8
|
12
|
+
# digits of the credit card number. It identifies the issuing bank.
|
13
|
+
#
|
14
|
+
# @return [String, nil]
|
7
15
|
attr_accessor :issuer_id_number
|
8
16
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
17
|
+
# The last two or four digits of the credit card number.
|
18
|
+
#
|
19
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--credit-card__last_digits
|
20
|
+
#
|
21
|
+
# @return [String, nil]
|
22
|
+
attr_accessor :last_digits
|
12
23
|
|
13
|
-
#
|
14
|
-
#
|
24
|
+
# The name of the issuing bank as provided by the end user.
|
25
|
+
#
|
26
|
+
# @return [String, nil]
|
15
27
|
attr_accessor :bank_name
|
16
28
|
|
17
|
-
#
|
18
|
-
#
|
29
|
+
# The phone country code for the issuing bank as provided by the end
|
30
|
+
# user. If you provide this information then you must provide at least
|
31
|
+
# one digit.
|
32
|
+
#
|
33
|
+
# @return [String, nil]
|
19
34
|
attr_accessor :bank_phone_country_code
|
20
35
|
|
21
|
-
#
|
22
|
-
#
|
36
|
+
# The phone number, without the country code, for the issuing bank as
|
37
|
+
# provided by the end user. Punctuation characters will be stripped.
|
38
|
+
# After stripping punctuation characters, the number must contain only
|
39
|
+
# digits.
|
40
|
+
#
|
41
|
+
# @return [String, nil]
|
23
42
|
attr_accessor :bank_phone_number
|
24
43
|
|
25
|
-
|
26
|
-
|
44
|
+
# The two character ISO 3166-1 alpha-2 country code where the issuer of
|
45
|
+
# the card is located. This may be passed instead of {::issuer_id_number}
|
46
|
+
# if you do not wish to pass partial account numbers, or if your payment
|
47
|
+
# processor does not provide them.
|
48
|
+
#
|
49
|
+
# @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
50
|
+
#
|
51
|
+
# @return [String, nil]
|
52
|
+
attr_accessor :country
|
53
|
+
|
54
|
+
# A token uniquely identifying the card. The token should consist of
|
55
|
+
# non-space printable ASCII characters. If the token is all digits, it
|
56
|
+
# must be more than 19 characters long. The token must not be a primary
|
57
|
+
# account number (PAN) or a simple transformation of it. If you have a
|
58
|
+
# valid token that looks like a PAN but is not one, you may prefix that
|
59
|
+
# token with a fixed string, e.g., +token-+.
|
60
|
+
#
|
61
|
+
# @return [String, nil]
|
27
62
|
attr_accessor :token
|
28
63
|
|
29
|
-
#
|
30
|
-
#
|
64
|
+
# The address verification system (AVS) check result, as returned to you
|
65
|
+
# by the credit card processor. The minFraud service supports the
|
66
|
+
# standard AVS codes.
|
67
|
+
#
|
68
|
+
# @return [String, nil]
|
31
69
|
attr_accessor :avs_result
|
32
70
|
|
33
|
-
#
|
34
|
-
#
|
71
|
+
# The card verification value (CVV) code as provided by the payment
|
72
|
+
# processor.
|
73
|
+
#
|
74
|
+
# @return [String, nil]
|
35
75
|
attr_accessor :cvv_result
|
36
76
|
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
77
|
+
# Whether the outcome of 3-D Secure verification (e.g. Safekey,
|
78
|
+
# SecureCode, Verified by Visa) was successful. +true+ if customer
|
79
|
+
# verification was successful, or +false+ if the customer failed
|
80
|
+
# verification. If 3-D Secure verification was not used, was unavailable,
|
81
|
+
# or resulted in an outcome other than success or failure, do not
|
82
|
+
# include this field.
|
83
|
+
#
|
84
|
+
# @return [Boolean, nil]
|
85
|
+
attr_accessor :was_3d_secure_successful
|
86
|
+
|
87
|
+
# Get the last digits of the credit card number.
|
88
|
+
#
|
89
|
+
# @deprecated Use {::last_digits} instead.
|
90
|
+
#
|
91
|
+
# @return [String, nil]
|
92
|
+
def last_4_digits
|
93
|
+
@last_digits
|
94
|
+
end
|
95
|
+
|
96
|
+
# Set the last digits of the credit card number.
|
97
|
+
#
|
98
|
+
# @deprecated Use {::last_digits} instead.
|
99
|
+
#
|
100
|
+
# @return [String, nil]
|
101
|
+
def last_4_digits=(last4)
|
102
|
+
@last_digits = last4
|
103
|
+
end
|
104
|
+
|
105
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
106
|
+
# correspond to one of the available attributes.
|
40
107
|
def initialize(params = {})
|
41
|
-
@bank_phone_country_code
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
108
|
+
@bank_phone_country_code = params[:bank_phone_country_code]
|
109
|
+
@country = params[:country]
|
110
|
+
@issuer_id_number = params[:issuer_id_number]
|
111
|
+
@last_digits = params[:last_digits] || params[:last_4_digits]
|
112
|
+
@bank_name = params[:bank_name]
|
113
|
+
@bank_phone_number = params[:bank_phone_number]
|
114
|
+
@avs_result = params[:avs_result]
|
115
|
+
@cvv_result = params[:cvv_result]
|
116
|
+
@token = params[:token]
|
117
|
+
@was_3d_secure_successful = params[:was_3d_secure_successful]
|
118
|
+
|
119
|
+
validate
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def validate
|
125
|
+
return if !Minfraud.enable_validation
|
126
|
+
|
127
|
+
validate_telephone_country_code('bank_phone_country_code', @bank_phone_country_code)
|
128
|
+
validate_country_code('country', @country)
|
129
|
+
validate_regex('issuer_id_number', /\A(?:[0-9]{6}|[0-9]{8})\z/, @issuer_id_number)
|
130
|
+
validate_regex('last_digits', /\A(?:[0-9]{2}|[0-9]{4})\z/, @last_digits)
|
131
|
+
validate_string('bank_name', 255, @bank_name)
|
132
|
+
validate_string('bank_phone_number', 255, @bank_phone_number)
|
133
|
+
validate_string('avs_result', 1, @avs_result)
|
134
|
+
validate_string('cvv_result', 1, @cvv_result)
|
135
|
+
validate_credit_card_token('token', @token)
|
136
|
+
validate_boolean('was_3d_secure_successful', @was_3d_secure_successful)
|
49
137
|
end
|
50
138
|
end
|
51
139
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minfraud
|
4
|
+
module Components
|
5
|
+
# CustomInputs corresponds to the custom_inputs object of a minFraud
|
6
|
+
# request.
|
7
|
+
#
|
8
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--custom-inputs
|
9
|
+
class CustomInputs < Base
|
10
|
+
include Minfraud::Validates
|
11
|
+
|
12
|
+
# @param params [Hash] Each key/value should correspond to your defined
|
13
|
+
# custom inputs.
|
14
|
+
def initialize(params = {})
|
15
|
+
params.each do |name, value|
|
16
|
+
instance_variable_set("@#{name}", value)
|
17
|
+
|
18
|
+
if Minfraud.enable_validation
|
19
|
+
validate_custom_input_value(name, value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,26 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Device corresponds to the device object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--device
|
3
8
|
class Device < Base
|
4
|
-
|
5
|
-
|
6
|
-
# The IP address
|
9
|
+
include Minfraud::Validates
|
10
|
+
|
11
|
+
# The IP address associated with the device used by the customer in the
|
12
|
+
# transaction. The IP address must be in IPv4 or IPv6 presentation
|
13
|
+
# format, i.e., dotted-quad notation or the IPv6 hexadecimal-colon
|
14
|
+
# notation.
|
15
|
+
#
|
16
|
+
# @return [String, nil]
|
7
17
|
attr_accessor :ip_address
|
8
18
|
|
9
|
-
#
|
10
|
-
#
|
19
|
+
# The HTTP "User-Agent" header of the browser used in the transaction.
|
20
|
+
#
|
21
|
+
# @return [String, nil]
|
11
22
|
attr_accessor :user_agent
|
12
23
|
|
13
|
-
#
|
14
|
-
#
|
24
|
+
# The HTTP "Accept-Language" header of the browser used in the
|
25
|
+
# transaction.
|
26
|
+
#
|
27
|
+
# @return [String, nil]
|
15
28
|
attr_accessor :accept_language
|
16
29
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
30
|
+
# The number of seconds between the creation of the user's session and
|
31
|
+
# the time of the transaction. Note that session_age is not the duration
|
32
|
+
# of the current visit, but the time since the start of the first visit.
|
33
|
+
# The value must be at least 0 and at most 10^13-1.
|
34
|
+
#
|
35
|
+
# @return [Float, nil]
|
36
|
+
attr_accessor :session_age
|
37
|
+
|
38
|
+
# An ID that uniquely identifies a visitor's session on the site.
|
39
|
+
#
|
40
|
+
# @return [String, nil]
|
41
|
+
attr_accessor :session_id
|
42
|
+
|
43
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
44
|
+
# correspond to one of the available attributes.
|
20
45
|
def initialize(params = {})
|
21
46
|
@ip_address = params[:ip_address]
|
22
47
|
@user_agent = params[:user_agent]
|
23
48
|
@accept_language = params[:accept_language]
|
49
|
+
@session_age = params[:session_age]
|
50
|
+
@session_id = params[:session_id]
|
51
|
+
|
52
|
+
validate
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def validate
|
58
|
+
return if !Minfraud.enable_validation
|
59
|
+
|
60
|
+
validate_ip('ip_address', @ip_address)
|
61
|
+
validate_string('user_agent', 512, @user_agent)
|
62
|
+
validate_string('accept_language', 255, @accept_language)
|
63
|
+
validate_nonnegative_number('session_age', @session_age)
|
64
|
+
validate_string('session_id', 255, @session_id)
|
24
65
|
end
|
25
66
|
end
|
26
67
|
end
|