Skip to content

Commit 22a950d

Browse files
authored
Msue 191 integration testing app new (#104)
Integration testing app
1 parent adbd15f commit 22a950d

16 files changed

Lines changed: 1642 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from decisions_api import test_decisions_api
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import sift
2+
import globals
3+
4+
from os import environ as env
5+
6+
class DecisionAPI():
7+
# Get the value of API_KEY from environment variable
8+
api_key = env['API_KEY']
9+
account_id = env['ACCOUNT_ID']
10+
client = sift.Client(api_key = api_key, account_id = account_id)
11+
globals.initialize()
12+
user_id = globals.user_id
13+
14+
def apply_user_decision(self):
15+
applyDecisionRequest = {
16+
"decision_id" : "block_user_payment_abuse",
17+
"source" : "MANUAL_REVIEW",
18+
"analyst" : "analyst@example.com",
19+
"description" : "User linked to three other payment abusers and ordering high value items"
20+
}
21+
22+
return self.client.apply_user_decision(self.user_id, applyDecisionRequest)
23+
24+
def apply_order_decision(self):
25+
applyOrderDecisionRequest = {
26+
"decision_id" : "block_order_payment_abuse",
27+
"source" : "AUTOMATED_RULE",
28+
"description" : "Auto block pending order as score exceeded risk threshold of 90"
29+
}
30+
31+
return self.client.apply_order_decision(self.user_id, "ORDER-1234567", applyOrderDecisionRequest)
32+
33+
def apply_session_decision(self):
34+
applySessionDecisionRequest = {
35+
"decision_id" : "session_looks_fraud_account_takover",
36+
"source" : "MANUAL_REVIEW",
37+
"analyst" : "analyst@example.com",
38+
"description" : "compromised account reported to customer service"
39+
}
40+
41+
return self.client.apply_session_decision(self.user_id, "session_id", applySessionDecisionRequest)
42+
43+
def apply_content_decision(self):
44+
applyContentDecisionRequest = {
45+
"decision_id" : "content_looks_fraud_content_abuse",
46+
"source" : "MANUAL_REVIEW",
47+
"analyst" : "analyst@example.com",
48+
"description" : "fraudulent listing"
49+
}
50+
51+
return self.client.apply_content_decision(self.user_id, "content_id", applyContentDecisionRequest)
52+
53+
def get_user_decisions(self):
54+
return self.client.get_user_decisions(self.user_id)
55+
56+
def get_order_decisions(self):
57+
return self.client.get_order_decisions("ORDER-1234567")
58+
59+
def get_content_decisions(self):
60+
return self.client.get_content_decisions(self.user_id, "CONTENT_ID")
61+
62+
def get_session_decisions(self):
63+
return self.client.get_session_decisions(self.user_id, "SESSION_ID")
64+
65+
def get_decisions(self):
66+
return self.client.get_decisions(entity_type='user', limit=10, start_from=5, abuse_types='legacy,payment_abuse')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from events_api import test_events_api

0 commit comments

Comments
 (0)