datadome_fraud_sdk_ruby 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/constants.rb +1 -1
- data/lib/datadome_fraud_sdk_ruby.rb +21 -13
- data/lib/model/address.rb +9 -9
- data/lib/model/api/request.rb +168 -45
- data/lib/model/api/response.rb +11 -6
- data/lib/model/location.rb +21 -0
- data/lib/model/session.rb +5 -5
- data/lib/model/user.rb +10 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2434a89b8290f901080492cb9491bfa2c56cf62da19504d1eb6ae987d411fdb
|
4
|
+
data.tar.gz: 121d6dbc02235af5e37c71a7acf58ce65bc1c8e3d65df37aea5e98ac115b8752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b9a208bff8a41ea879cc4e70584f63156af5892b8cc2402647d112224902f071bc98b769903aa445ce5afebdde5d316de7064b1123028929a148cc63a4bce1
|
7
|
+
data.tar.gz: bebb991f6d5bd9f9c1faef493473e145cef3f4755b0633e26671d604e6ee0d39413d3f5f7c30c24adea391d52ce0d11364693de07f9c93841874a54a5a774445
|
data/lib/constants.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
SDK_VERSION = '
|
1
|
+
SDK_VERSION = '2.0.0'
|
2
2
|
SDK_NAME = 'datadome_fraud_sdk_ruby'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "faraday"
|
4
4
|
require "json"
|
5
5
|
require_relative "model/events"
|
6
|
+
require_relative "model/location"
|
6
7
|
require_relative "model/user"
|
7
8
|
require_relative "model/session"
|
8
9
|
require_relative "model/operation"
|
@@ -36,13 +37,13 @@ class DataDome
|
|
36
37
|
end
|
37
38
|
|
38
39
|
if api_response.success?
|
39
|
-
datadome_response = DataDomeResponseSuccess.new(DataDomeResponseAction::ALLOW, DataDomeResponseStatus::OK, body["reasons"], body["ip"], body["location"])
|
40
|
+
datadome_response = DataDomeResponseSuccess.new(DataDomeResponseAction::ALLOW, DataDomeResponseStatus::OK, body["reasons"], body["ip"], DataDomeLocation.new(location: body["location"]))
|
40
41
|
if body["action"] === DataDomeResponseAction::DENY
|
41
42
|
datadome_response.action = DataDomeResponseAction::DENY
|
42
43
|
end
|
43
44
|
else
|
44
45
|
@logger.error("DataDome: error on Fraud API /validate response #{body["errors"]}")
|
45
|
-
return DataDomeResponseError.new(DataDomeResponseAction::ALLOW, DataDomeResponseStatus::FAILURE, body["message"], body["errors"])
|
46
|
+
return DataDomeResponseError.new(DataDomeResponseAction::ALLOW, DataDomeResponseStatus::FAILURE, body["message"], body["errors"].map { |error| DataDomeError.new(error) })
|
46
47
|
end
|
47
48
|
rescue Faraday::TimeoutError => e
|
48
49
|
return DataDomeResponseError.new(DataDomeResponseAction::ALLOW, DataDomeResponseStatus::TIMEOUT, "DataDome Fraud API request timeout", e.message)
|
@@ -69,7 +70,7 @@ class DataDome
|
|
69
70
|
begin
|
70
71
|
body = JSON.parse(api_response.body)
|
71
72
|
@logger.error("DataDome: error on Fraud API /collect response #{body["errors"]}")
|
72
|
-
datadome_response = DataDomeResponseError.new(nil, DataDomeResponseStatus::FAILURE, body["message"], body["errors"])
|
73
|
+
datadome_response = DataDomeResponseError.new(nil, DataDomeResponseStatus::FAILURE, body["message"], body["errors"].map { |error| DataDomeError.new(error) })
|
73
74
|
rescue JSON::ParserError => e
|
74
75
|
@logger.error("DataDome: error parsing JSON from Fraud API /collect #{e.message}")
|
75
76
|
return DataDomeResponseError.new(nil, DataDomeResponseStatus::FAILURE, "DataDome: error parsing JSON from Fraud API", e.message)
|
@@ -86,6 +87,23 @@ class DataDome
|
|
86
87
|
|
87
88
|
private
|
88
89
|
|
90
|
+
def build_payload(request, event)
|
91
|
+
# Check if the request is an instance of DataDomeRequest
|
92
|
+
if request.instance_of?(DataDomeRequest)
|
93
|
+
# If it is, simply merge the event data with the request data
|
94
|
+
payload = event.merge_with(request)
|
95
|
+
else
|
96
|
+
# If it's not, create a new instance of DataDomeHeaders
|
97
|
+
datadome_headers = DataDomeHeaders.new
|
98
|
+
# Populate the DataDomeHeaders instance with data from the HTTP request
|
99
|
+
datadome_headers.build_from_http_request(request)
|
100
|
+
# Create a new DataDomeRequest instance with the DataDomeHeaders instance
|
101
|
+
# and merge the event data with the DataDomeRequest
|
102
|
+
payload = event.merge_with(DataDomeRequest.new(datadome_headers))
|
103
|
+
end
|
104
|
+
payload
|
105
|
+
end
|
106
|
+
|
89
107
|
def send_request(operation, event, payload)
|
90
108
|
api_response = client.post("/v1/" + operation + "/" + event) do |req|
|
91
109
|
req.body = payload.to_json
|
@@ -93,16 +111,6 @@ class DataDome
|
|
93
111
|
api_response
|
94
112
|
end
|
95
113
|
|
96
|
-
def build_payload(request, event)
|
97
|
-
metadata = event.merge_with(DataDomeRequest.new(request))
|
98
|
-
payload = {}
|
99
|
-
metadata.instance_variables.each do |var|
|
100
|
-
key = var.to_s.delete("@") # Remove '@' from variable name to get key
|
101
|
-
payload[key] = metadata.instance_variable_get(var)
|
102
|
-
end
|
103
|
-
payload
|
104
|
-
end
|
105
|
-
|
106
114
|
def client
|
107
115
|
Faraday.new(api_uri) do |req|
|
108
116
|
req.adapter Faraday.default_adapter
|
data/lib/model/address.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class DataDomeAddress
|
4
|
-
attr_accessor :name, :line1, :line2, :city, :
|
4
|
+
attr_accessor :name, :line1, :line2, :city, :country_code, :region_code, :zip_code
|
5
5
|
|
6
|
-
def initialize(name: nil, line1: nil, line2: nil, city: nil,
|
6
|
+
def initialize(name: nil, line1: nil, line2: nil, city: nil, country_code: nil, region_code: nil, zip_code: nil)
|
7
7
|
@name = name
|
8
8
|
@line1 = line1
|
9
9
|
@line2 = line2
|
10
10
|
@city = city
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
11
|
+
@country_code = country_code
|
12
|
+
@region_code = region_code
|
13
|
+
@zip_code = zip_code
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_s
|
17
|
-
"DataDomeAddress: name=#{name}, line1=#{line1}, line2=#{line2}, city=#{city}, countryCode=#{
|
17
|
+
"DataDomeAddress: name=#{@name}, line1=#{@line1}, line2=#{@line2}, city=#{@city}, countryCode=#{@country_code}, regionCode=#{@region_code}, zipCode=#{@zip_code}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_json(options = {})
|
@@ -23,9 +23,9 @@ class DataDomeAddress
|
|
23
23
|
line1: line1,
|
24
24
|
line2: line2,
|
25
25
|
city: city,
|
26
|
-
countryCode:
|
27
|
-
regionCode:
|
28
|
-
zipCode:
|
26
|
+
countryCode: country_code,
|
27
|
+
regionCode: region_code,
|
28
|
+
zipCode: zip_code,
|
29
29
|
}.to_json
|
30
30
|
end
|
31
31
|
end
|
data/lib/model/api/request.rb
CHANGED
@@ -3,80 +3,203 @@
|
|
3
3
|
require_relative "../../constants"
|
4
4
|
|
5
5
|
class DataDomeModule
|
6
|
-
|
6
|
+
attr_reader :request_time_micros, :name, :version
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
@
|
9
|
+
@request_time_micros = Time.now.strftime("%s%6N").to_i
|
10
10
|
@name = "Fraud SDK Ruby"
|
11
11
|
@version = SDK_VERSION
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def to_hash
|
15
15
|
{
|
16
|
-
requestTimeMicros: @
|
16
|
+
requestTimeMicros: @request_time_micros,
|
17
17
|
name: @name,
|
18
18
|
version: @version,
|
19
|
-
}
|
19
|
+
}
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class DataDomeHeaders
|
24
|
-
attr_accessor :addr, :
|
25
|
-
:
|
26
|
-
:referer, :
|
27
|
-
:
|
28
|
-
:
|
24
|
+
attr_accessor :addr, :client_ip, :content_type, :host, :port, :x_real_ip, :x_forwarded_for_ip,
|
25
|
+
:accept_encoding, :accept_language, :accept, :method, :protocol, :server_hostname,
|
26
|
+
:referer, :user_agent, :from, :request, :origin, :accept_charset, :connection,
|
27
|
+
:client_id, :sec_ch_ua, :sec_ch_ua_mobile, :sec_ch_ua_platform, :sec_ch_ua_arch,
|
28
|
+
:sec_ch_ua_full_version_list, :sec_ch_ua_model, :sec_ch_device_memory
|
29
|
+
|
30
|
+
def initialize(addr: nil, client_ip: nil, content_type: nil, host: nil, port: nil, x_real_ip: nil,
|
31
|
+
x_forwarded_for_ip: nil, accept_encoding: nil, accept_language: nil, accept: nil,
|
32
|
+
method: nil, protocol: nil, server_hostname: nil, referer: nil, user_agent: nil,
|
33
|
+
from: nil, request: nil, origin: nil, accept_charset: nil, connection: nil,
|
34
|
+
client_id: nil, sec_ch_ua: nil, sec_ch_ua_mobile: nil, sec_ch_ua_platform: nil,
|
35
|
+
sec_ch_ua_arch: nil, sec_ch_ua_full_version_list: nil, sec_ch_ua_model: nil,
|
36
|
+
sec_ch_device_memory: nil)
|
37
|
+
@addr = addr
|
38
|
+
@client_ip = client_ip
|
39
|
+
@content_type = content_type
|
40
|
+
@host = host
|
41
|
+
@port = port
|
42
|
+
@x_real_ip = x_real_ip
|
43
|
+
@x_forwarded_for_ip = x_forwarded_for_ip
|
44
|
+
@accept_encoding = accept_encoding
|
45
|
+
@accept_language = accept_language
|
46
|
+
@accept = accept
|
47
|
+
@method = method
|
48
|
+
@protocol = protocol
|
49
|
+
@server_hostname = server_hostname
|
50
|
+
@referer = referer
|
51
|
+
@user_agent = user_agent
|
52
|
+
@from = from
|
53
|
+
@request = request
|
54
|
+
@origin = origin
|
55
|
+
@accept_charset = accept_charset
|
56
|
+
@connection = connection
|
57
|
+
@client_id = client_id
|
58
|
+
@sec_ch_ua = sec_ch_ua
|
59
|
+
@sec_ch_ua_mobile = sec_ch_ua_mobile
|
60
|
+
@sec_ch_ua_platform = sec_ch_ua_platform
|
61
|
+
@sec_ch_ua_arch = sec_ch_ua_arch
|
62
|
+
@sec_ch_ua_full_version_list = sec_ch_ua_full_version_list
|
63
|
+
@sec_ch_ua_model = sec_ch_ua_model
|
64
|
+
@sec_ch_device_memory = sec_ch_device_memory
|
65
|
+
end
|
29
66
|
|
30
|
-
def
|
67
|
+
def build_from_http_request(request)
|
31
68
|
@addr = request.remote_ip
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@host =
|
69
|
+
@client_ip = request.headers["HTTP_CLIENT_IP"]
|
70
|
+
@content_type = request.headers["Content-Type"] # this value is a meta-variable of the request
|
71
|
+
@host = request.headers["HTTP_HOST"]
|
35
72
|
@port = request.port || 0
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@accept =
|
73
|
+
@x_real_ip = request.headers["HTTP_X_REAL_IP"]
|
74
|
+
@x_forwarded_for_ip = request.headers["HTTP_X_FORWARDED_FOR"]
|
75
|
+
@accept_encoding = request.headers["HTTP_ACCEPT_ENCODING"]
|
76
|
+
@accept_language = request.headers["HTTP_ACCEPT_LANGUAGE"]
|
77
|
+
@accept = request.headers["HTTP_ACCEPT"]
|
41
78
|
@method = request.method
|
42
79
|
@protocol = request.protocol.gsub("://", "")
|
43
|
-
@
|
44
|
-
@referer =
|
45
|
-
@
|
46
|
-
@from =
|
47
|
-
@request = [request.path, request.query_string].reject(&:blank?).join("?")
|
48
|
-
@origin =
|
49
|
-
@
|
50
|
-
@connection =
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@
|
80
|
+
@server_hostname = request.headers["HTTP_HOST"]
|
81
|
+
@referer = request.headers["HTTP_REFERER"]
|
82
|
+
@user_agent = request.headers["HTTP_USER_AGENT"]
|
83
|
+
@from = request.headers["HTTP_FROM"]
|
84
|
+
@request = [request.path, request.query_string].reject(&:blank?).join("?")
|
85
|
+
@origin = request.headers["HTTP_ORIGIN"]
|
86
|
+
@accept_charset = request.headers["HTTP_ACCEPT_CHARSET"]
|
87
|
+
@connection = request.headers["HTTP_CONNECTION"]
|
88
|
+
@client_id = request.cookies["datadome"]
|
89
|
+
@sec_ch_ua = request.headers["HTTP_SEC_CH_UA"]
|
90
|
+
@sec_ch_ua_mobile = request.headers["HTTP_SEC_CH_UA_MOBILE"]
|
91
|
+
@sec_ch_ua_platform = request.headers["HTTP_SEC_CH_UA_PLATFORM"]
|
92
|
+
@sec_ch_ua_arch = request.headers["HTTP_SEC_CH_UA_ARCH"]
|
93
|
+
@sec_ch_ua_full_version_list = request.headers["HTTP_SEC_CH_UA_FULL_VERSION_LIST"]
|
94
|
+
@sec_ch_ua_model = request.headers["HTTP_SEC_CH_UA_MODEL"]
|
95
|
+
@sec_ch_device_memory = request.headers["HTTP_SEC_CH_DEVICE_MEMORY"]
|
59
96
|
end
|
60
97
|
|
61
|
-
def
|
62
|
-
|
98
|
+
def truncate_attributes
|
99
|
+
# Hash containing the headers size limit
|
100
|
+
headers_max_length = {
|
101
|
+
addr: nil, # No size limit
|
102
|
+
client_ip: nil,
|
103
|
+
content_type: 64,
|
104
|
+
host: 512,
|
105
|
+
port: nil,
|
106
|
+
x_real_ip: 128,
|
107
|
+
x_forwarded_for_ip: -512, # Truncate backwards
|
108
|
+
accept_encoding: 128,
|
109
|
+
accept_language: 256,
|
110
|
+
accept: 512,
|
111
|
+
method: nil,
|
112
|
+
protocol: nil,
|
113
|
+
server_hostname: 256,
|
114
|
+
referer: 1024,
|
115
|
+
user_agent: 768,
|
116
|
+
from: 128,
|
117
|
+
request: 2048,
|
118
|
+
origin: 512,
|
119
|
+
accept_charset: 128,
|
120
|
+
connection: 128,
|
121
|
+
client_id: nil,
|
122
|
+
sec_ch_ua: 128,
|
123
|
+
sec_ch_ua_mobile: 8,
|
124
|
+
sec_ch_ua_platform: 32,
|
125
|
+
sec_ch_ua_arch: 16,
|
126
|
+
sec_ch_ua_full_version_list: 256,
|
127
|
+
sec_ch_ua_model: 128,
|
128
|
+
sec_ch_device_memory: 8,
|
129
|
+
}
|
130
|
+
|
131
|
+
headers_max_length.each do |attribute, max_size|
|
132
|
+
next unless self.respond_to?("#{attribute}=") # Skip if attribute setter method doesn't exist
|
133
|
+
|
134
|
+
value = self.send(attribute) # Get the value of the attribute dynamically
|
135
|
+
next unless value.is_a?(String) # Skip if the value is not a string
|
63
136
|
|
64
|
-
|
137
|
+
if max_size && value.length > max_size
|
138
|
+
# Truncate the value if it exceeds the max size
|
139
|
+
truncated_value = max_size < 0 ? value[max_size] : value[0, max_size]
|
140
|
+
self.send("#{attribute}=", truncated_value) # Set the truncated value to the attribute
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def to_hash
|
146
|
+
{
|
147
|
+
addr: @addr,
|
148
|
+
clientIp: @client_ip,
|
149
|
+
contentType: @content_type,
|
150
|
+
host: @host,
|
151
|
+
port: @port,
|
152
|
+
xRealIP: @x_real_ip,
|
153
|
+
xForwardedForIp: @x_forwarded_for_ip,
|
154
|
+
acceptEncoding: @accept_encoding,
|
155
|
+
acceptLanguage: @accept_language,
|
156
|
+
accept: @accept,
|
157
|
+
method: @method,
|
158
|
+
protocol: @protocol,
|
159
|
+
serverHostname: @server_hostname,
|
160
|
+
referer: @referer,
|
161
|
+
userAgent: @user_agent,
|
162
|
+
from: @from,
|
163
|
+
request: @request,
|
164
|
+
origin: @origin,
|
165
|
+
acceptCharset: @accept_charset,
|
166
|
+
connection: @connection,
|
167
|
+
clientID: @client_id,
|
168
|
+
secCHUA: @sec_ch_ua,
|
169
|
+
secCHUAMobile: @sec_ch_ua_mobile,
|
170
|
+
secCHUAPlatform: @sec_ch_ua_platform,
|
171
|
+
secCHUAArch: @sec_ch_ua_arch,
|
172
|
+
secCHUAFullVersionList: @sec_ch_ua_full_version_list,
|
173
|
+
secCHUAModel: @sec_ch_ua_model,
|
174
|
+
secCHDeviceMemory: @sec_ch_device_memory,
|
175
|
+
}
|
65
176
|
end
|
66
177
|
end
|
67
178
|
|
68
179
|
class DataDomeRequest
|
69
|
-
|
180
|
+
attr_reader :module, :header, :account, :status, :session, :user
|
70
181
|
|
71
|
-
def initialize(
|
182
|
+
def initialize(datadome_headers)
|
72
183
|
@module = DataDomeModule.new
|
73
|
-
@header =
|
184
|
+
@header = datadome_headers
|
185
|
+
# Do not forget headers truncation
|
186
|
+
@header.truncate_attributes
|
187
|
+
# Dynamic attributes that holds Event data when payload is created
|
188
|
+
@account = {}
|
189
|
+
@status = {}
|
190
|
+
@session = {}
|
191
|
+
@user = {}
|
74
192
|
end
|
75
193
|
|
76
194
|
def to_json(options = {})
|
77
|
-
{
|
78
|
-
module: @module.
|
79
|
-
header: @header.
|
80
|
-
|
195
|
+
data = {
|
196
|
+
module: @module.to_hash,
|
197
|
+
header: @header.to_hash,
|
198
|
+
account: @account,
|
199
|
+
status: @status,
|
200
|
+
session: @session,
|
201
|
+
user: @user,
|
202
|
+
}
|
203
|
+
JSON.generate(data, options)
|
81
204
|
end
|
82
205
|
end
|
data/lib/model/api/response.rb
CHANGED
@@ -12,7 +12,12 @@ module DataDomeResponseStatus
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class DataDomeError
|
15
|
-
|
15
|
+
attr_reader :field, :error
|
16
|
+
|
17
|
+
def initialize(error)
|
18
|
+
@field = error&.fetch("field", nil)
|
19
|
+
@error = error&.fetch("error", nil)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
class DataDomeResponse
|
@@ -24,7 +29,7 @@ class DataDomeResponse
|
|
24
29
|
end
|
25
30
|
|
26
31
|
def to_s
|
27
|
-
"DataDomeResponse: action=#{action}, status=#{status}"
|
32
|
+
"DataDomeResponse: action=#{@action}, status=#{@status}"
|
28
33
|
end
|
29
34
|
|
30
35
|
def to_json(options = {})
|
@@ -36,7 +41,7 @@ class DataDomeResponse
|
|
36
41
|
end
|
37
42
|
|
38
43
|
class DataDomeResponseSuccess < DataDomeResponse
|
39
|
-
|
44
|
+
attr_reader :ip, :reasons, :location
|
40
45
|
|
41
46
|
def initialize(action, status, reasons, ip, location)
|
42
47
|
super(action, status)
|
@@ -46,7 +51,7 @@ class DataDomeResponseSuccess < DataDomeResponse
|
|
46
51
|
end
|
47
52
|
|
48
53
|
def to_s
|
49
|
-
"DataDomeResponseSuccess: action=#{action}, status=#{status}, reasons=#{reasons}, ip=#{ip}, location=#{location}"
|
54
|
+
"DataDomeResponseSuccess: action=#{@action}, status=#{@status}, reasons=#{@reasons}, ip=#{@ip}, location=#{@location}"
|
50
55
|
end
|
51
56
|
|
52
57
|
def to_json(options = {})
|
@@ -61,7 +66,7 @@ class DataDomeResponseSuccess < DataDomeResponse
|
|
61
66
|
end
|
62
67
|
|
63
68
|
class DataDomeResponseError < DataDomeResponse
|
64
|
-
|
69
|
+
attr_reader :message, :errors
|
65
70
|
|
66
71
|
def initialize(action, status, message, errors)
|
67
72
|
super(action, status)
|
@@ -70,7 +75,7 @@ class DataDomeResponseError < DataDomeResponse
|
|
70
75
|
end
|
71
76
|
|
72
77
|
def to_s
|
73
|
-
"DataDomeResponseError: action=#{action}, status=#{status}, message=#{message}, errors=#{errors}"
|
78
|
+
"DataDomeResponseError: action=#{@action}, status=#{@status}, message=#{@message}, errors=#{@errors}"
|
74
79
|
end
|
75
80
|
|
76
81
|
def to_json(options = {})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class DataDomeLocation
|
2
|
+
attr_reader :country_code, :country, :city
|
3
|
+
|
4
|
+
def initialize(location: nil)
|
5
|
+
@country_code = location&.fetch("countryCode", nil)
|
6
|
+
@country = location&.fetch("country", nil)
|
7
|
+
@city = location&.fetch("city", nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
"DataDomeLocation: countryCode=#{@country_code}, country=#{@country}, city=#{@city}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_json(options = {})
|
15
|
+
{
|
16
|
+
countryCode: @country_code,
|
17
|
+
country: @country,
|
18
|
+
city: @city,
|
19
|
+
}.to_json
|
20
|
+
end
|
21
|
+
end
|
data/lib/model/session.rb
CHANGED
@@ -3,21 +3,21 @@
|
|
3
3
|
require "time"
|
4
4
|
|
5
5
|
class DataDomeSession
|
6
|
-
attr_reader :id, :
|
6
|
+
attr_reader :id, :created_at
|
7
7
|
|
8
|
-
def initialize(id:,
|
8
|
+
def initialize(id:, created_at: Time.now.iso8601)
|
9
9
|
@id = id
|
10
|
-
@
|
10
|
+
@created_at = created_at
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_s
|
14
|
-
"DataDomeSession: id=#{id}, createdAt =#{
|
14
|
+
"DataDomeSession: id=#{@id}, createdAt =#{@created_at}"
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_json(options = {})
|
18
18
|
{
|
19
19
|
id: id,
|
20
|
-
createdAt:
|
20
|
+
createdAt: created_at,
|
21
21
|
}.to_json
|
22
22
|
end
|
23
23
|
end
|
data/lib/model/user.rb
CHANGED
@@ -11,27 +11,29 @@ module DataDomeTitle
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class DataDomeUser
|
14
|
-
|
14
|
+
attr_accessor :id, :title, :first_name, :last_name, :created_at, :phone, :email, :address
|
15
|
+
|
16
|
+
def initialize(id:, title: nil, first_name: nil, last_name: nil, created_at: Time.now.iso8601, phone: nil, email: nil, address: nil)
|
15
17
|
@id = id
|
16
18
|
@title = title
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
19
|
+
@first_name = first_name
|
20
|
+
@last_name = last_name
|
21
|
+
@created_at = created_at
|
20
22
|
@phone = phone
|
21
23
|
@email = email
|
22
24
|
@address = address
|
23
25
|
end
|
24
26
|
|
25
27
|
def to_s
|
26
|
-
"DataDomeUser: id=#{id}, title
|
28
|
+
"DataDomeUser: id=#{@id}, title=#{@title}, firstName=#{@first_name}, lastName=#{@last_name}, createdAt=#{@created_at}, phone=#{@phone}, address=#{@address}"
|
27
29
|
end
|
28
30
|
|
29
31
|
def to_json(options = {})
|
30
32
|
{
|
31
33
|
id: @id,
|
32
|
-
firstName: @
|
33
|
-
lastName: @
|
34
|
-
createdAt: @
|
34
|
+
firstName: @first_name,
|
35
|
+
lastName: @last_name,
|
36
|
+
createdAt: @created_at,
|
35
37
|
phone: @phone,
|
36
38
|
email: @email,
|
37
39
|
address: @address,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadome_fraud_sdk_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DataDome
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/model/api/request.rb
|
38
38
|
- lib/model/api/response.rb
|
39
39
|
- lib/model/events.rb
|
40
|
+
- lib/model/location.rb
|
40
41
|
- lib/model/operation.rb
|
41
42
|
- lib/model/session.rb
|
42
43
|
- lib/model/user.rb
|