-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
110 lines (85 loc) · 3.09 KB
/
app.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import flask
import datetime
from flask import request, jsonify
from mockData import employees, leaveBalances, leave, pays, roster
app = flask.Flask(__name__)
app.config['DEBUG'] = True
@app.route('/', methods=['GET'])
def home():
return "<h1>Shay's App Testing API</h1> <p>This API is used for creating and testing web and mobile applications</p>"
@app.route('/api/uscorr/auth/employee', methods=['GET'])
def getEmployees():
# id should be a valid employee number
if 'id' in request.args:
id = int(request.args['id'])
else:
return "Error: No id field was provided. Specify an id field containing a valid employee number"
results = []
for employee in employees:
if employee['employeeNumber'] == id:
results.append(employee)
if len(results) < 1:
return "No match for found for the specified employee number"
else:
return jsonify(results)
@app.route('/api/uscorr/sap/balances', methods=['GET'])
def getLeaveBalances():
# id should be a valid employee number
if 'id' in request.args:
id = int(request.args['id'])
else:
return "Error: No id field was provided. Specify an id field containing a valid employee number"
results = []
for balance in leaveBalances:
if balance['employeeNumber'] == id:
results.append(balance)
if len(results) < 1:
return "No match for found for the specified employee number"
else:
return jsonify(results)
@app.route('/api/uscorr/sap/pay', methods=['GET'])
def getPays():
# id should be a valid employee number
if 'id' in request.args:
id = int(request.args['id'])
else:
return "Error: No id field was provided. Specify an id field containing a valid employee number"
results = []
for pay in pays:
if pay['employeeNumber'] == id:
results.append(pay)
if len(results) < 1:
return "No match for found for the specified employee number"
else:
return jsonify(results)
@app.route('/api/uscorr/sap/leave', methods=['GET'])
def getLeave():
# id should be a valid employee number
if 'id' in request.args:
id = int(request.args['id'])
else:
return "Error: No id field was provided. Specify an id field containing a valid employee number"
results = []
for app in leave:
if app['employeeNumber'] == id:
results.append(app)
if len(results) < 1:
return "No match for found for the specified employee number"
else:
return jsonify(results)
@app.route('/api/uscorr/roster', methods=['GET'])
def getRoster():
# id should be a valid employee number
if 'id' in request.args:
id = int(request.args['id'])
else:
return "Error: No id field was provided. Specify an id field containing a valid employee number"
results = []
for shift in roster:
if shift['employeeNumber'] == id:
results.append(shift)
if len(results) < 1:
return "No match for found for the specified employee number"
else:
return jsonify(results)
app.run()