sift 4.4.0 → 4.5.1
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/.github/workflows/ci.yml +49 -0
- data/HISTORY +6 -0
- data/README.md +33 -2
- data/lib/sift/client.rb +17 -9
- data/lib/sift/version.rb +2 -1
- data/lib/sift.rb +3 -3
- data/spec/unit/client_spec.rb +30 -0
- data/test_integration_app/decisions_api/test_decisions_api.rb +31 -0
- data/test_integration_app/events_api/test_events_api.rb +843 -0
- data/test_integration_app/globals.rb +2 -0
- data/test_integration_app/main.rb +67 -0
- data/test_integration_app/psp_merchants_api/test_psp_merchant_api.rb +44 -0
- data/test_integration_app/score_api/test_score_api.rb +11 -0
- data/test_integration_app/verification_api/test_verification_api.rb +32 -0
- metadata +13 -6
- data/.circleci/config.yml +0 -88
@@ -0,0 +1,843 @@
|
|
1
|
+
require "sift"
|
2
|
+
|
3
|
+
class EventsAPI
|
4
|
+
|
5
|
+
@@client = Sift::Client.new(:api_key => ENV["API_KEY"])
|
6
|
+
|
7
|
+
def login()
|
8
|
+
|
9
|
+
# Sample $login event
|
10
|
+
properties = {
|
11
|
+
# Required Fields
|
12
|
+
"$user_id" => $user_id,
|
13
|
+
"$login_status" => "$failure",
|
14
|
+
|
15
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
16
|
+
"$ip" => "128.148.1.135",
|
17
|
+
|
18
|
+
# Optional Fields
|
19
|
+
"$user_email" => $user_email,
|
20
|
+
"$failure_reason" => "$account_unknown",
|
21
|
+
"$username" => "billjones1@example.com",
|
22
|
+
"$account_types" => ["merchant", "premium"],
|
23
|
+
"$social_sign_on_type" => "$linkedin",
|
24
|
+
"$brand_name" => "sift",
|
25
|
+
"$site_domain" => "sift.com",
|
26
|
+
"$site_country" => "US",
|
27
|
+
|
28
|
+
# Send this information with a login from a BROWSER client.
|
29
|
+
"$browser" => {
|
30
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
31
|
+
"$accept_language" => "en-US",
|
32
|
+
"$content_language" => "en-GB"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
return @@client.track("$login", properties)
|
37
|
+
end
|
38
|
+
|
39
|
+
def transaction()
|
40
|
+
|
41
|
+
# Sample $transaction event
|
42
|
+
properties = {
|
43
|
+
# Required Fields
|
44
|
+
"$user_id" => $user_id,
|
45
|
+
"$amount" => 506790000, # $506.79
|
46
|
+
"$currency_code" => "USD",
|
47
|
+
|
48
|
+
# Supported Fields
|
49
|
+
"$user_email" => $user_email,
|
50
|
+
"$transaction_type" => "$sale",
|
51
|
+
"$transaction_status" => "$failure",
|
52
|
+
"$decline_category" => "$bank_decline",
|
53
|
+
"$order_id" => "ORDER-123124124",
|
54
|
+
"$transaction_id" => "719637215",
|
55
|
+
|
56
|
+
"$billing_address" => { # or "$sent_address" # or "$received_address"
|
57
|
+
"$name" => "Bill Jones",
|
58
|
+
"$phone" => "1-415-555-6041",
|
59
|
+
"$address_1" => "2100 Main Street",
|
60
|
+
"$address_2" => "Apt 3B",
|
61
|
+
"$city" => "New London",
|
62
|
+
"$region" => "New Hampshire",
|
63
|
+
"$country" => "US",
|
64
|
+
"$zipcode" => "03257"
|
65
|
+
},
|
66
|
+
"$brand_name" => "sift",
|
67
|
+
"$site_domain" => "sift.com",
|
68
|
+
"$site_country" => "US",
|
69
|
+
"$ordered_from" => {
|
70
|
+
"$store_id" => "123",
|
71
|
+
"$store_address" => {
|
72
|
+
"$name" => "Bill Jones",
|
73
|
+
"$phone" => "1-415-555-6040",
|
74
|
+
"$address_1" => "2100 Main Street",
|
75
|
+
"$address_2" => "Apt 3B",
|
76
|
+
"$city" => "New London",
|
77
|
+
"$region" => "New Hampshire",
|
78
|
+
"$country" => "US",
|
79
|
+
"$zipcode" => "03257"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
# Credit card example
|
83
|
+
"$payment_method" => {
|
84
|
+
"$payment_type" => "$credit_card",
|
85
|
+
"$payment_gateway" => "$braintree",
|
86
|
+
"$card_bin" => "542486",
|
87
|
+
"$card_last4" => "4444"
|
88
|
+
},
|
89
|
+
|
90
|
+
# Supported fields for 3DS
|
91
|
+
"$status_3ds" => "$attempted",
|
92
|
+
"$triggered_3ds" => "$processor",
|
93
|
+
"$merchant_initiated_transaction" => false,
|
94
|
+
|
95
|
+
# Supported Fields
|
96
|
+
"$shipping_address" => {
|
97
|
+
"$name" => "Bill Jones",
|
98
|
+
"$phone" => "1-415-555-6041",
|
99
|
+
"$address_1" => "2100 Main Street",
|
100
|
+
"$address_2" => "Apt 3B",
|
101
|
+
"$city" => "New London",
|
102
|
+
"$region" => "New Hampshire",
|
103
|
+
"$country" => "US",
|
104
|
+
"$zipcode" => "03257"
|
105
|
+
},
|
106
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
107
|
+
|
108
|
+
# For marketplaces, use $seller_user_id to identify the seller
|
109
|
+
"$seller_user_id" => "slinkys_emporium",
|
110
|
+
|
111
|
+
# Sample Custom Fields
|
112
|
+
"digital_wallet" => "apple_pay", # "google_wallet", etc.
|
113
|
+
"coupon_code" => "dollarMadness",
|
114
|
+
"shipping_choice" => "FedEx Ground Courier",
|
115
|
+
"is_first_time_buyer" => false,
|
116
|
+
|
117
|
+
# Send this information from a BROWSER client.
|
118
|
+
"$browser" => {
|
119
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
120
|
+
"$accept_language" => "en-US",
|
121
|
+
"$content_language" => "en-GB"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
return @@client.track("$transaction", properties, :warnings => 'true')
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_order()
|
129
|
+
|
130
|
+
# Sample $create_order event
|
131
|
+
properties = {
|
132
|
+
# Required Fields
|
133
|
+
"$user_id" => $user_id,
|
134
|
+
# Supported Fields
|
135
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
136
|
+
"$order_id" => "ORDER-28168441",
|
137
|
+
"$user_email" => $user_email,
|
138
|
+
"$amount" => 115940000, # $115.94
|
139
|
+
"$currency_code" => "USD",
|
140
|
+
"$billing_address" => {
|
141
|
+
"$name" => "Bill Jones",
|
142
|
+
"$phone" => "1-415-555-6041",
|
143
|
+
"$address_1" => "2100 Main Street",
|
144
|
+
"$address_2" => "Apt 3B",
|
145
|
+
"$city" => "New London",
|
146
|
+
"$region" => "New Hampshire",
|
147
|
+
"$country" => "US",
|
148
|
+
"$zipcode" => "03257"
|
149
|
+
},
|
150
|
+
"$payment_methods" => [
|
151
|
+
{
|
152
|
+
"$payment_type" => "$credit_card",
|
153
|
+
"$payment_gateway" => "$braintree",
|
154
|
+
"$card_bin" => "542486",
|
155
|
+
"$card_last4" => "4444"
|
156
|
+
}
|
157
|
+
],
|
158
|
+
"$ordered_from" => {
|
159
|
+
"$store_id" => "123",
|
160
|
+
"$store_address" => {
|
161
|
+
"$name" => "Bill Jones",
|
162
|
+
"$phone" => "1-415-555-6040",
|
163
|
+
"$address_1" => "2100 Main Street",
|
164
|
+
"$address_2" => "Apt 3B",
|
165
|
+
"$city" => "New London",
|
166
|
+
"$region" => "New Hampshire",
|
167
|
+
"$country" => "US",
|
168
|
+
"$zipcode" => "03257"
|
169
|
+
}
|
170
|
+
},
|
171
|
+
"$brand_name" => "sift",
|
172
|
+
"$site_domain" => "sift.com",
|
173
|
+
"$site_country" => "US",
|
174
|
+
"$shipping_address" => {
|
175
|
+
"$name" => "Bill Jones",
|
176
|
+
"$phone" => "1-415-555-6041",
|
177
|
+
"$address_1" => "2100 Main Street",
|
178
|
+
"$address_2" => "Apt 3B",
|
179
|
+
"$city" => "New London",
|
180
|
+
"$region" => "New Hampshire",
|
181
|
+
"$country" => "US",
|
182
|
+
"$zipcode" => "03257"
|
183
|
+
},
|
184
|
+
"$expedited_shipping" => true,
|
185
|
+
"$shipping_method" => "$physical",
|
186
|
+
"$shipping_carrier" => "UPS",
|
187
|
+
"$shipping_tracking_numbers"=> ["1Z204E380338943508", "1Z204E380338943509"],
|
188
|
+
"$items" => [
|
189
|
+
{
|
190
|
+
"$item_id" => "12344321",
|
191
|
+
"$product_title" => "Microwavable Kettle Corn: Original Flavor",
|
192
|
+
"$price" => 4990000, # $4.99
|
193
|
+
"$upc" => "097564307560",
|
194
|
+
"$sku" => "03586005",
|
195
|
+
"$brand" => "Peters Kettle Corn",
|
196
|
+
"$manufacturer" => "Peters Kettle Corn",
|
197
|
+
"$category" => "Food and Grocery",
|
198
|
+
"$tags" => ["Popcorn", "Snacks", "On Sale"],
|
199
|
+
"$quantity" => 4
|
200
|
+
},
|
201
|
+
{
|
202
|
+
"$item_id" => "B004834GQO",
|
203
|
+
"$product_title" => "The Slanket Blanket-Texas Tea",
|
204
|
+
"$price" => 39990000, # $39.99
|
205
|
+
"$upc" => "6786211451001",
|
206
|
+
"$sku" => "004834GQ",
|
207
|
+
"$brand" => "Slanket",
|
208
|
+
"$manufacturer" => "Slanket",
|
209
|
+
"$category" => "Blankets & Throws",
|
210
|
+
"$tags" => ["Awesome", "Wintertime specials"],
|
211
|
+
"$color" => "Texas Tea",
|
212
|
+
"$quantity" => 2
|
213
|
+
}
|
214
|
+
],
|
215
|
+
# For marketplaces, use $seller_user_id to identify the seller
|
216
|
+
"$seller_user_id" => "slinkys_emporium",
|
217
|
+
|
218
|
+
"$promotions" => [
|
219
|
+
{
|
220
|
+
"$promotion_id" => "FirstTimeBuyer",
|
221
|
+
"$status" => "$success",
|
222
|
+
"$description" => "$5 off",
|
223
|
+
"$discount" => {
|
224
|
+
"$amount" => 5000000, # $5.00
|
225
|
+
"$currency_code" => "USD",
|
226
|
+
"$minimum_purchase_amount" => 25000000 # $25.00
|
227
|
+
}
|
228
|
+
}
|
229
|
+
],
|
230
|
+
|
231
|
+
# Sample Custom Fields
|
232
|
+
"digital_wallet" => "apple_pay", # "google_wallet", etc.
|
233
|
+
"coupon_code" => "dollarMadness",
|
234
|
+
"shipping_choice" => "FedEx Ground Courier",
|
235
|
+
"is_first_time_buyer" => false,
|
236
|
+
|
237
|
+
# Send this information from a BROWSER client.
|
238
|
+
"$browser" => {
|
239
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
240
|
+
"$accept_language" => "en-US",
|
241
|
+
"$content_language" => "en-GB"
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
return @@client.track("$create_order", properties)
|
246
|
+
end
|
247
|
+
|
248
|
+
def create_content()
|
249
|
+
|
250
|
+
# Sample $create_content event for comments
|
251
|
+
comment_properties = {
|
252
|
+
# Required fields
|
253
|
+
'$user_id' => $user_id,
|
254
|
+
'$content_id' => 'comment-23412',
|
255
|
+
|
256
|
+
# Recommended fields
|
257
|
+
'$session_id' => 'a234ksjfgn435sfg',
|
258
|
+
'$status' => '$active',
|
259
|
+
'$ip' => '255.255.255.0',
|
260
|
+
|
261
|
+
# Required $comment object
|
262
|
+
'$comment' => {
|
263
|
+
'$body' => 'Congrats on the new role!',
|
264
|
+
'$contact_email' => 'alex_301@domain.com',
|
265
|
+
'$parent_comment_id' => 'comment-23407',
|
266
|
+
'$root_content_id' => 'listing-12923213',
|
267
|
+
'$images' => [
|
268
|
+
{
|
269
|
+
'$md5_hash' => '0cc175b9c0f1b6a831c399e269772661',
|
270
|
+
'$link' => 'https://www.domain.com/file.png',
|
271
|
+
'$description' => 'An old picture'
|
272
|
+
}
|
273
|
+
]
|
274
|
+
},
|
275
|
+
|
276
|
+
# Send this information from an APP client.
|
277
|
+
"$app" => {
|
278
|
+
# Example for the iOS Calculator app.
|
279
|
+
"$os" => "iOS",
|
280
|
+
"$os_version" => "10.1.3",
|
281
|
+
"$device_manufacturer" => "Apple",
|
282
|
+
"$device_model" => "iPhone 4,2",
|
283
|
+
"$device_unique_id" => "A3D261E4-DE0A-470B-9E4A-720F3D3D22E6",
|
284
|
+
"$app_name" => "Calculator",
|
285
|
+
"$app_version" => "3.2.7",
|
286
|
+
"$client_language" => "en-US"
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
return @@client.track("$create_content", comment_properties)
|
291
|
+
end
|
292
|
+
|
293
|
+
def create_content_listing()
|
294
|
+
|
295
|
+
# Sample $create_content event for listings
|
296
|
+
listing_properties = {
|
297
|
+
# Required fields
|
298
|
+
'$user_id' => $user_id,
|
299
|
+
'$content_id' => 'listing-23412',
|
300
|
+
|
301
|
+
# Recommended fields
|
302
|
+
'$session_id' => 'a234ksjfgn435sfg',
|
303
|
+
'$status' => '$active',
|
304
|
+
'$ip' => '255.255.255.0',
|
305
|
+
|
306
|
+
# Required $listing object
|
307
|
+
'$listing' => {
|
308
|
+
'$subject' => '2 Bedroom Apartment for Rent',
|
309
|
+
'$body' => 'Capitol Hill Seattle brand new condo. 2 bedrooms and 1 full bath.',
|
310
|
+
'$contact_email' => 'alex_301@domain.com',
|
311
|
+
'$contact_address' => {
|
312
|
+
'$name' => 'Bill Jones',
|
313
|
+
'$phone' => '1-415-555-6041',
|
314
|
+
'$city' => 'New London',
|
315
|
+
'$region' => 'New Hampshire',
|
316
|
+
'$country' => 'US',
|
317
|
+
'$zipcode' => '03257'
|
318
|
+
},
|
319
|
+
'$locations' => [
|
320
|
+
{
|
321
|
+
'$city' => 'Seattle',
|
322
|
+
'$region' => 'Washington',
|
323
|
+
'$country' => 'US',
|
324
|
+
'$zipcode' => '98112'
|
325
|
+
}
|
326
|
+
],
|
327
|
+
'$listed_items' => [
|
328
|
+
{
|
329
|
+
'$price' => 2950000000, # $2950.00
|
330
|
+
'$currency_code' => 'USD',
|
331
|
+
'$tags' => ['heat', 'washer/dryer']
|
332
|
+
}
|
333
|
+
],
|
334
|
+
'$images' => [
|
335
|
+
{
|
336
|
+
'$md5_hash' => '0cc175b9c0f1b6a831c399e269772661',
|
337
|
+
'$link' => 'https://www.domain.com/file.png',
|
338
|
+
'$description' => 'Billy’s picture'
|
339
|
+
}
|
340
|
+
],
|
341
|
+
'$expiration_time' => 1549063157000 # UNIX timestamp in milliseconds
|
342
|
+
},
|
343
|
+
|
344
|
+
# Send this information from an APP client.
|
345
|
+
"$app" => {
|
346
|
+
# Example for the iOS Calculator app.
|
347
|
+
"$os" => "iOS",
|
348
|
+
"$os_version" => "10.1.3",
|
349
|
+
"$device_manufacturer" => "Apple",
|
350
|
+
"$device_model" => "iPhone 4,2",
|
351
|
+
"$device_unique_id" => "A3D261E4-DE0A-470B-9E4A-720F3D3D22E6",
|
352
|
+
"$app_name" => "Calculator",
|
353
|
+
"$app_version" => "3.2.7",
|
354
|
+
"$client_language" => "en-US"
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
return @@client.track("$create_content", listing_properties)
|
359
|
+
end
|
360
|
+
|
361
|
+
def create_content_message()
|
362
|
+
|
363
|
+
# Sample $create_content event for posts
|
364
|
+
post_properties = {
|
365
|
+
# Required fields
|
366
|
+
'$user_id' => $user_id,
|
367
|
+
'$content_id' => 'post-23412',
|
368
|
+
|
369
|
+
# Recommended fields
|
370
|
+
'$session_id' => 'a234ksjfgn435sfg',
|
371
|
+
'$status' => '$active',
|
372
|
+
'$ip' => '255.255.255.0',
|
373
|
+
|
374
|
+
# Required $post object
|
375
|
+
'$post' => {
|
376
|
+
'$subject' => 'My new apartment!',
|
377
|
+
'$body' => 'Moved into my new apartment yesterday.',
|
378
|
+
'$contact_email' => 'alex_301@domain.com',
|
379
|
+
'$contact_address' => {
|
380
|
+
'$name' => 'Bill Jones',
|
381
|
+
'$city' => 'New London',
|
382
|
+
'$region' => 'New Hampshire',
|
383
|
+
'$country' => 'US',
|
384
|
+
'$zipcode' => '03257'
|
385
|
+
},
|
386
|
+
'$locations' => [
|
387
|
+
{
|
388
|
+
'$city' => 'Seattle',
|
389
|
+
'$region' => 'Washington',
|
390
|
+
'$country' => 'US',
|
391
|
+
'$zipcode' => '98112'
|
392
|
+
}
|
393
|
+
],
|
394
|
+
'$categories' => ['Personal'],
|
395
|
+
'$images' => [
|
396
|
+
{
|
397
|
+
'$md5_hash' => '0cc175b9c0f1b6a831c399e269772661',
|
398
|
+
'$link' => 'https://www.domain.com/file.png',
|
399
|
+
'$description' => 'View from the window!'
|
400
|
+
}
|
401
|
+
],
|
402
|
+
'$expiration_time' => 1549063157000 # UNIX timestamp in milliseconds
|
403
|
+
},
|
404
|
+
|
405
|
+
# Send this information from a BROWSER client.
|
406
|
+
"$browser" => {
|
407
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
408
|
+
"$accept_language" => "en-US",
|
409
|
+
"$content_language" => "en-GB"
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
return @@client.track("$create_content", post_properties)
|
414
|
+
end
|
415
|
+
|
416
|
+
def update_account()
|
417
|
+
|
418
|
+
# Sample $update_account event
|
419
|
+
properties = {
|
420
|
+
# Required Fields
|
421
|
+
"$user_id" => $user_id,
|
422
|
+
|
423
|
+
# Supported Fields
|
424
|
+
"$changed_password" => true,
|
425
|
+
"$user_email" => $user_email,
|
426
|
+
"$name" => "Bill Jones",
|
427
|
+
"$phone" => "1-415-555-6040",
|
428
|
+
"$referrer_user_id" => "janejane102",
|
429
|
+
"$payment_methods" => [
|
430
|
+
{
|
431
|
+
"$payment_type" => "$credit_card",
|
432
|
+
"$card_bin" => "542486",
|
433
|
+
"$card_last4" => "4444"
|
434
|
+
}
|
435
|
+
],
|
436
|
+
"$billing_address" =>
|
437
|
+
{
|
438
|
+
"$name" => "Bill Jones",
|
439
|
+
"$phone" => "1-415-555-6041",
|
440
|
+
"$address_1" => "2100 Main Street",
|
441
|
+
"$address_2" => "Apt 3B",
|
442
|
+
"$city" => "New London",
|
443
|
+
"$region" => "New Hampshire",
|
444
|
+
"$country" => "US",
|
445
|
+
"$zipcode" => "03257"
|
446
|
+
},
|
447
|
+
"$shipping_address" => {
|
448
|
+
"$name" => "Bill Jones",
|
449
|
+
"$phone" => "1-415-555-6041",
|
450
|
+
"$address_1" => "2100 Main Street",
|
451
|
+
"$address_2" => "Apt 3B",
|
452
|
+
"$city" => "New London",
|
453
|
+
"$region" => "New Hampshire",
|
454
|
+
"$country" => "US",
|
455
|
+
"$zipcode" => "03257"
|
456
|
+
},
|
457
|
+
|
458
|
+
"$social_sign_on_type" => "$twitter",
|
459
|
+
"$account_types" => ["merchant", "premium"],
|
460
|
+
|
461
|
+
# Send this information from a BROWSER client.
|
462
|
+
"$browser" => {
|
463
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
464
|
+
"$accept_language" => "en-US",
|
465
|
+
"$content_language" => "en-GB"
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
return @@client.track("$update_account", properties)
|
470
|
+
end
|
471
|
+
|
472
|
+
def update_content_listing()
|
473
|
+
|
474
|
+
# Sample $update_content event for listings
|
475
|
+
listing_properties = {
|
476
|
+
# Required fields
|
477
|
+
'$user_id' => $user_id,
|
478
|
+
'$content_id' => 'listing-23412',
|
479
|
+
|
480
|
+
# Recommended fields
|
481
|
+
'$session_id' => 'a234ksjfgn435sfg',
|
482
|
+
'$status' => '$active',
|
483
|
+
'$ip' => '255.255.255.0',
|
484
|
+
|
485
|
+
# Required $listing object
|
486
|
+
'$listing' => {
|
487
|
+
'$subject' => '2 Bedroom Apartment for Rent',
|
488
|
+
'$body' => 'Capitol Hill Seattle brand new condo. 2 bedrooms and 1 full bath.',
|
489
|
+
'$contact_email' => 'alex_301@domain.com',
|
490
|
+
'$contact_address' => {
|
491
|
+
'$name' => 'Bill Jones',
|
492
|
+
'$phone' => '1-415-555-6041',
|
493
|
+
'$city' => 'New London',
|
494
|
+
'$region' => 'New Hampshire',
|
495
|
+
'$country' => 'US',
|
496
|
+
'$zipcode' => '03257'
|
497
|
+
},
|
498
|
+
'$locations' => [
|
499
|
+
{
|
500
|
+
'$city' => 'Seattle',
|
501
|
+
'$region' => 'Washington',
|
502
|
+
'$country' => 'US',
|
503
|
+
'$zipcode' => '98112'
|
504
|
+
}
|
505
|
+
],
|
506
|
+
'$listed_items' => [
|
507
|
+
{
|
508
|
+
'$price' => 2950000000, # $2950.00
|
509
|
+
'$currency_code' => 'USD',
|
510
|
+
'$tags' => ['heat', 'washer/dryer']
|
511
|
+
}
|
512
|
+
],
|
513
|
+
'$images' => [
|
514
|
+
{
|
515
|
+
'$md5_hash' => '0cc175b9c0f1b6a831c399e269772661',
|
516
|
+
'$link' => 'https://www.domain.com/file.png',
|
517
|
+
'$description' => 'Billys picture'
|
518
|
+
}
|
519
|
+
],
|
520
|
+
'$expiration_time' => 1549063157000 # UNIX timestamp in milliseconds
|
521
|
+
},
|
522
|
+
|
523
|
+
# Send this information from a BROWSER client.
|
524
|
+
"$browser" => {
|
525
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
526
|
+
"$accept_language" => "en-US",
|
527
|
+
"$content_language" => "en-GB"
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
return @@client.track("$update_content", listing_properties)
|
532
|
+
end
|
533
|
+
|
534
|
+
def create_account()
|
535
|
+
|
536
|
+
# Sample $create_account event
|
537
|
+
properties = {
|
538
|
+
# Required Fields
|
539
|
+
"$user_id" => $user_id,
|
540
|
+
|
541
|
+
# Supported Fields
|
542
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
543
|
+
"$user_email" => $user_email,
|
544
|
+
"$name" => "Bill Jones",
|
545
|
+
"$phone" => "1-415-555-6040",
|
546
|
+
"$referrer_user_id" => "janejane101",
|
547
|
+
"$payment_methods" => [
|
548
|
+
{
|
549
|
+
"$payment_type" => "$credit_card",
|
550
|
+
"$card_bin" => "542486",
|
551
|
+
"$card_last4" => "4444"
|
552
|
+
}
|
553
|
+
],
|
554
|
+
"$billing_address" => {
|
555
|
+
"$name" => "Bill Jones",
|
556
|
+
"$phone" => "1-415-555-6040",
|
557
|
+
"$address_1" => "2100 Main Street",
|
558
|
+
"$address_2" => "Apt 3B",
|
559
|
+
"$city" => "New London",
|
560
|
+
"$region" => "New Hampshire",
|
561
|
+
"$country" => "US",
|
562
|
+
"$zipcode" => "03257"
|
563
|
+
},
|
564
|
+
"$shipping_address" => {
|
565
|
+
"$name" => "Bill Jones",
|
566
|
+
"$phone" => "1-415-555-6041",
|
567
|
+
"$address_1" => "2100 Main Street",
|
568
|
+
"$address_2" => "Apt 3B",
|
569
|
+
"$city" => "New London",
|
570
|
+
"$region" => "New Hampshire",
|
571
|
+
"$country" => "US",
|
572
|
+
"$zipcode" => "03257"
|
573
|
+
},
|
574
|
+
"$promotions" => [
|
575
|
+
{
|
576
|
+
"$promotion_id" => "FriendReferral",
|
577
|
+
"$status" => "$success",
|
578
|
+
"$referrer_user_id" => "janejane102",
|
579
|
+
"$credit_point" => {
|
580
|
+
"$amount" => 100,
|
581
|
+
"$credit_point_type" => "account karma"
|
582
|
+
}
|
583
|
+
}
|
584
|
+
],
|
585
|
+
|
586
|
+
"$social_sign_on_type" => "$twitter",
|
587
|
+
"$account_types" => ["merchant", "premium"],
|
588
|
+
|
589
|
+
# Suggested Custom Fields
|
590
|
+
"twitter_handle" => "billyjones",
|
591
|
+
"work_phone" => "1-347-555-5921",
|
592
|
+
"location" => "New London, NH",
|
593
|
+
"referral_code" => "MIKEFRIENDS",
|
594
|
+
"email_confirmed_status" => "$pending",
|
595
|
+
"phone_confirmed_status" => "$pending",
|
596
|
+
|
597
|
+
# Send this information from a BROWSER client.
|
598
|
+
"$browser" => {
|
599
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
600
|
+
"$accept_language" => "en-US",
|
601
|
+
"$content_language" => "en-GB"
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
return @@client.track("$create_account", properties)
|
606
|
+
end
|
607
|
+
|
608
|
+
def verification()
|
609
|
+
|
610
|
+
# Sample $verification event
|
611
|
+
properties = {
|
612
|
+
# Required Fields
|
613
|
+
"$user_id" => $user_id,
|
614
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
615
|
+
"$status" => "$pending",
|
616
|
+
|
617
|
+
# Optional fields if applicable
|
618
|
+
"$verified_event" => "$login",
|
619
|
+
"$reason" => "$automated_rule", # Verification was triggered based on risk score
|
620
|
+
"$verification_type" => "$sms",
|
621
|
+
"$verified_value" => "14155551212"
|
622
|
+
}
|
623
|
+
|
624
|
+
return @@client.track("$verification", properties)
|
625
|
+
end
|
626
|
+
|
627
|
+
def add_item_to_cart()
|
628
|
+
|
629
|
+
# Sample $add_item_to_cart event
|
630
|
+
properties = {
|
631
|
+
# Required Fields
|
632
|
+
"$user_id" => $user_id,
|
633
|
+
|
634
|
+
# Supported Fields
|
635
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
636
|
+
"$item" => {
|
637
|
+
"$item_id" => "B004834GQO",
|
638
|
+
"$product_title" => "The Slanket Blanket-Texas Tea",
|
639
|
+
"$price" => 39990000, # $39.99
|
640
|
+
"$currency_code" => "USD",
|
641
|
+
"$upc" => "6786211451001",
|
642
|
+
"$sku" => "004834GQ",
|
643
|
+
"$brand" => "Slanket",
|
644
|
+
"$manufacturer" => "Slanket",
|
645
|
+
"$category" => "Blankets & Throws",
|
646
|
+
"$tags" => ["Awesome", "Wintertime specials"],
|
647
|
+
"$color" => "Texas Tea",
|
648
|
+
"$quantity" => 16
|
649
|
+
},
|
650
|
+
"$brand_name" => "sift",
|
651
|
+
"$site_domain" => "sift.com",
|
652
|
+
"$site_country" => "US",
|
653
|
+
# Send this information from a BROWSER client.
|
654
|
+
"$browser" => {
|
655
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
656
|
+
"$accept_language" => "en-US",
|
657
|
+
"$content_language" => "en-GB"
|
658
|
+
}
|
659
|
+
}
|
660
|
+
|
661
|
+
return @@client.track("$add_item_to_cart", properties)
|
662
|
+
end
|
663
|
+
|
664
|
+
def order_status()
|
665
|
+
|
666
|
+
# Sample $order_status event
|
667
|
+
properties = {
|
668
|
+
# Required Fields
|
669
|
+
"$user_id" => $user_id,
|
670
|
+
"$order_id" => "ORDER-28168441",
|
671
|
+
"$order_status" => "$canceled",
|
672
|
+
|
673
|
+
# Optional Fields
|
674
|
+
"$reason" => "$payment_risk",
|
675
|
+
"$webhook_id" => "3ff1082a4aea8d0c58e3643ddb7a5bb87ffffeb2492dca33",
|
676
|
+
"$source" => "$manual_review",
|
677
|
+
"$analyst" => "someone@your-site.com",
|
678
|
+
"$description" => "Canceling because multiple fraudulent users on device",
|
679
|
+
|
680
|
+
# Send this information from a BROWSER client.
|
681
|
+
"$browser" => {
|
682
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
683
|
+
"$accept_language" => "en-US",
|
684
|
+
"$content_language" => "en-GB"
|
685
|
+
}
|
686
|
+
}
|
687
|
+
|
688
|
+
return @@client.track("$order_status", properties)
|
689
|
+
end
|
690
|
+
|
691
|
+
def link_session_to_user()
|
692
|
+
|
693
|
+
# Sample $link_session_to_user event
|
694
|
+
properties = {
|
695
|
+
# Required Fields
|
696
|
+
"$user_id" => $user_id,
|
697
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il"
|
698
|
+
}
|
699
|
+
|
700
|
+
return @@client.track("$link_session_to_user", properties)
|
701
|
+
end
|
702
|
+
|
703
|
+
def content_status()
|
704
|
+
|
705
|
+
# Sample $content_status event
|
706
|
+
properties = {
|
707
|
+
# Required Fields
|
708
|
+
"$user_id" => $user_id,
|
709
|
+
"$content_id" => "9671500641",
|
710
|
+
"$status" => "$paused",
|
711
|
+
|
712
|
+
# Send this information from a BROWSER client.
|
713
|
+
"$browser" => {
|
714
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
715
|
+
"$accept_language" => "en-US",
|
716
|
+
"$content_language" => "en-GB"
|
717
|
+
}
|
718
|
+
}
|
719
|
+
|
720
|
+
return @@client.track("$content_status", properties)
|
721
|
+
end
|
722
|
+
|
723
|
+
def update_order()
|
724
|
+
|
725
|
+
# Sample $update_order event
|
726
|
+
properties = {
|
727
|
+
# Required Fields
|
728
|
+
"$user_id" => $user_id,
|
729
|
+
# Supported Fields
|
730
|
+
"$session_id" => "gigtleqddo84l8cm15qe4il",
|
731
|
+
"$order_id" => "ORDER-28168441",
|
732
|
+
"$user_email" => $user_email,
|
733
|
+
"$amount" => 115940000, # $115.94
|
734
|
+
"$currency_code" => "USD",
|
735
|
+
"$billing_address" => {
|
736
|
+
"$name" => "Bill Jones",
|
737
|
+
"$phone" => "1-415-555-6041",
|
738
|
+
"$address_1" => "2100 Main Street",
|
739
|
+
"$address_2" => "Apt 3B",
|
740
|
+
"$city" => "New London",
|
741
|
+
"$region" => "New Hampshire",
|
742
|
+
"$country" => "US",
|
743
|
+
"$zipcode" => "03257"
|
744
|
+
},
|
745
|
+
"$payment_methods" => [
|
746
|
+
{
|
747
|
+
"$payment_type" => "$credit_card",
|
748
|
+
"$payment_gateway" => "$braintree",
|
749
|
+
"$card_bin" => "542486",
|
750
|
+
"$card_last4" => "4444"
|
751
|
+
}
|
752
|
+
],
|
753
|
+
"$brand_name" => "sift",
|
754
|
+
"$site_domain" => "sift.com",
|
755
|
+
"$site_country" => "US",
|
756
|
+
"$ordered_from" => {
|
757
|
+
"$store_id" => "123",
|
758
|
+
"$store_address" => {
|
759
|
+
"$name" => "Bill Jones",
|
760
|
+
"$phone" => "1-415-555-6040",
|
761
|
+
"$address_1" => "2100 Main Street",
|
762
|
+
"$address_2" => "Apt 3B",
|
763
|
+
"$city" => "New London",
|
764
|
+
"$region" => "New Hampshire",
|
765
|
+
"$country" => "US",
|
766
|
+
"$zipcode" => "03257"
|
767
|
+
}
|
768
|
+
},
|
769
|
+
"$shipping_address" => {
|
770
|
+
"$name" => "Bill Jones",
|
771
|
+
"$phone" => "1-415-555-6041",
|
772
|
+
"$address_1" => "2100 Main Street",
|
773
|
+
"$address_2" => "Apt 3B",
|
774
|
+
"$city" => "New London",
|
775
|
+
"$region" => "New Hampshire",
|
776
|
+
"$country" => "US",
|
777
|
+
"$zipcode" => "03257"
|
778
|
+
},
|
779
|
+
"$expedited_shipping" => true,
|
780
|
+
"$shipping_method" => "$physical",
|
781
|
+
"$shipping_carrier" => "UPS",
|
782
|
+
"$shipping_tracking_numbers"=> ["1Z204E380338943508", "1Z204E380338943509"],
|
783
|
+
"$items" => [
|
784
|
+
{
|
785
|
+
"$item_id" => "12344321",
|
786
|
+
"$product_title" => "Microwavable Kettle Corn: Original Flavor",
|
787
|
+
"$price" => 4990000, # $4.99
|
788
|
+
"$upc" => "097564307560",
|
789
|
+
"$sku" => "03586005",
|
790
|
+
"$brand" => "Peters Kettle Corn",
|
791
|
+
"$manufacturer" => "Peters Kettle Corn",
|
792
|
+
"$category" => "Food and Grocery",
|
793
|
+
"$tags" => ["Popcorn", "Snacks", "On Sale"],
|
794
|
+
"$quantity" => 4
|
795
|
+
},
|
796
|
+
{
|
797
|
+
"$item_id" => "B004834GQO",
|
798
|
+
"$product_title" => "The Slanket Blanket-Texas Tea",
|
799
|
+
"$price" => 39990000, # $39.99
|
800
|
+
"$upc" => "6786211451001",
|
801
|
+
"$sku" => "004834GQ",
|
802
|
+
"$brand" => "Slanket",
|
803
|
+
"$manufacturer" => "Slanket",
|
804
|
+
"$category" => "Blankets & Throws",
|
805
|
+
"$tags" => ["Awesome", "Wintertime specials"],
|
806
|
+
"$color" => "Texas Tea",
|
807
|
+
"$quantity" => 2
|
808
|
+
}
|
809
|
+
],
|
810
|
+
# For marketplaces, use $seller_user_id to identify the seller
|
811
|
+
"$seller_user_id" => "slinkys_emporium",
|
812
|
+
|
813
|
+
"$promotions" => [
|
814
|
+
{
|
815
|
+
"$promotion_id" => "FirstTimeBuyer",
|
816
|
+
"$status" => "$success",
|
817
|
+
"$description" => "$5 off",
|
818
|
+
"$discount" => {
|
819
|
+
"$amount" => 5000000, # $5.00
|
820
|
+
"$currency_code" => "USD",
|
821
|
+
"$minimum_purchase_amount" => 25000000 # $25.00
|
822
|
+
}
|
823
|
+
}
|
824
|
+
],
|
825
|
+
|
826
|
+
# Sample Custom Fields
|
827
|
+
"digital_wallet" => "apple_pay", # "google_wallet", etc.
|
828
|
+
"coupon_code" => "dollarMadness",
|
829
|
+
"shipping_choice" => "FedEx Ground Courier",
|
830
|
+
"is_first_time_buyer" => false,
|
831
|
+
|
832
|
+
# Send this information from a BROWSER client.
|
833
|
+
"$browser" => {
|
834
|
+
"$user_agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
835
|
+
"$accept_language" => "en-US",
|
836
|
+
"$content_language" => "en-GB"
|
837
|
+
}
|
838
|
+
}
|
839
|
+
|
840
|
+
return @@client.track("$update_order", properties)
|
841
|
+
end
|
842
|
+
|
843
|
+
end
|