-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathget-flight-status.txt
38 lines (35 loc) · 1.02 KB
/
get-flight-status.txt
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
/**
*
* main() will be run when you invoke this action
*
* @param Cloud Functions actions accept a single parameter, which must be a JSON object.
*
* @return The output of this action, which must be a JSON object.
*
*/
function main(params) {
returnString = '';
airline = params.airline;
flightNum = params.flightNumber;
fullQual = airline + flightNum;
// This section could be an API call, database call, etc.
switch(fullQual){
case 'AA456':
returnString = 'AA456 is 10 minutes ahead of schedule.';
break;
case 'AA123':
returnString = 'AA123 is on time.';
break;
case 'DL123':
returnString = 'DL123 is on time.';
break;
case 'UA789':
returnString = 'UA789 is 5 minutes behind schedule.';
break;
default:
returnString = '**An error has occured.**';
}
//
let finalString = " --> " + returnString + " <-- ";
return { message: finalString };
}