-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsumer.robot
65 lines (57 loc) · 2.1 KB
/
consumer.robot
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
56
57
58
59
60
61
62
63
64
65
*** Settings ***
Documentation Inhuman Insurance, Inc. Artificial Intelligence System robot.
... Consumes traffic data work items.
Resource shared.robot
*** Tasks ***
Consume traffic data work items
For Each Input Work Item Process traffic data
*** Keywords ***
Process traffic data
${payload}= Get Work Item Payload
${traffic_data}= Set Variable ${payload}[${WORK_ITEM_NAME}]
${valid}= Validate traffic data ${traffic_data}
IF ${valid}
Post traffic data to sales system ${traffic_data}
ELSE
Handle invalid traffic data ${traffic_data}
END
Validate traffic data
[Arguments] ${traffic_data}
${country}= Get Value From Json ${traffic_data} $.country
${valid}= Evaluate len("${country}") == 3
[Return] ${valid}
Post traffic data to sales system
[Arguments] ${traffic_data}
${status} ${return} Run Keyword And Ignore Error
... POST
... https://robocorp.com/inhuman-insurance-inc/sales-system-api
... json=${traffic_data}
Handle traffic API response ${status} ${return} ${traffic_data}
Handle traffic API response
[Arguments] ${status} ${return} ${traffic_data}
IF "${status}" == "PASS"
Handle traffic API OK response
ELSE
Handle traffic API error response ${return} ${traffic_data}
END
Handle traffic API OK response
Release Input Work Item DONE
Handle traffic API error response
[Arguments] ${return} ${traffic_data}
Log
... Traffic data posting failed: ${traffic_data} ${return}
... ERROR
Release Input Work Item
... state=FAILED
... exception_type=APPLICATION
... code=TRAFFIC_DATA_POST_FAILED
... message=${return}
Handle invalid traffic data
[Arguments] ${traffic_data}
${message}= Set Variable Invalid traffic data: ${traffic_data}
Log ${message} WARN
Release Input Work Item
... state=FAILED
... exception_type=BUSINESS
... code=INVALID_TRAFFIC_DATA
... message=${message}