Skip to content

Commit c286ad6

Browse files
author
erangi-ar
committed
feat: Implement agency existence check before insertion in add.yml
1 parent c1a56a4 commit c286ad6

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Check if agency exists in mock_centops table
2+
SELECT agency_id
3+
FROM public.mock_centops
4+
WHERE agency_id = :agencyId;

DSL/Ruuter.public/global-classifier/POST/centops/add.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ extractRequestData:
2222
assign:
2323
agency_id: ${incoming.body.agency_id}
2424
agency_name: ${incoming.body.agency_name}
25+
next: checkAgencyExists
26+
27+
# Check if Agency Already Exists
28+
checkAgencyExists:
29+
call: http.post
30+
args:
31+
url: "[#GLOBAL_CLASSIFIER_RESQL]/get-agency-centops"
32+
body:
33+
agencyId: ${agency_id}
34+
result: agency_check_res
35+
next: evaluateAgencyExistence
36+
37+
# Evaluate Agency Existence
38+
evaluateAgencyExistence:
39+
switch:
40+
- condition: "${agency_check_res.response.body.length > 0}"
41+
next: return_agency_exists
2542
next: insertAgencyData
2643

2744
# Insert Agency Data
@@ -48,6 +65,11 @@ return_success:
4865
status: 200
4966
next: end
5067

68+
return_agency_exists:
69+
return: "error: agency already exists in centops"
70+
status: 400
71+
next: end
72+
5173
return_insert_failed:
5274
return: "error: failed to add agency to centops"
5375
status: 500

0 commit comments

Comments
 (0)