-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction signup_alert(p).lua
More file actions
55 lines (50 loc) · 1.84 KB
/
function signup_alert(p).lua
File metadata and controls
55 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function signup_warning_level(p)
if(p == nil) then
return {
ref = "signup_warning_level",
name = "Signup Warning Level",
description = "This trigger will set the warning level when a customer signs up",
priority = 0,
triggerType = "PRE_CREATE",
triggerOptions = {"CUSTOMER"},
api = "TRIGGER",
version = 1,
}
end
print("========== CALLED ==========")
local warningkey = checkBeKey(p.beUUID, 'SIGNUP_WARNING_SET') --Set BE key value
if(warningkey.success) then
print("========== START SETTING WARNING LEVEL ==========")
p.input:setWarningLevel(500) --change warning level value(Only a double will be accepeted)
print("========== COMPLETE SETTING WARNING LEVEL==========")
end
return { exitState = "SUCCESS" }
end
function checkBeKey(beUUID, resourceKeyName)
local searchFilter = new("SearchFilter")
local filterCondition1 = new("FilterCondition")
filterCondition1:setField('resourceuuid')
filterCondition1:setValue({beUUID})
filterCondition1:setCondition(new("Condition","IS_EQUAL_TO"))
local filterCondition2 = new("FilterCondition")
filterCondition2:setField('resourcekey.name')
filterCondition2:setValue({resourceKeyName})
filterCondition2:setCondition(new("Condition","IS_EQUAL_TO"))
searchFilter:addCondition(filterCondition1)
searchFilter:addCondition(filterCondition2)
local billingEntity = adminAPI:listResources(searchFilter,nil,new("ResourceType","BILLING_ENTITY"))
if(billingEntity:getList():size() == 1) then
for i = 0, billingEntity:getList():get(0):getResourceKey():size() - 1, 1 do
if(billingEntity:getList():get(0):getResourceKey():get(i):getName() == resourceKeyName) then
return {success = true, keyValue = billingEntity:getList():get(0):getResourceKey():get(i):getValue() }
end
end
else
return {success = false}
end
end
function register()
return {
"signup_warning_level",
}
end