-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
46 lines (36 loc) · 1.08 KB
/
run.py
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
# Built-in libraries
import sys
import json
# Project libraries
from app.service.logging import logger
from app.auth.authorizer import Authorizer
from app.parse.io import parse_input_events
from app.auth.validation.custom_validation import *
def main() -> None:
"""
Runs the entire application flow
Returns:
None
"""
events = parse_input_events()
if events:
logger.info('Starting events processing.')
auth = Authorizer(
events=events,
validations=[
CardNotActiveValidation,
InsufficientLimitValidation,
HighFreqSmallIntervalValidation,
DoubledTransaction
]
)
for processed_event in auth.process():
# Write event to stdout
sys.stdout.write(
f"{json.dumps(processed_event, default=str, sort_keys=True)}\n"
)
logger.info("Done! All events have been processed.")
else:
logger.warning('No events found. Skipping execution.')
if __name__ == '__main__':
main()