-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDB_API_Documentation.txt
More file actions
181 lines (123 loc) · 5.22 KB
/
DB_API_Documentation.txt
File metadata and controls
181 lines (123 loc) · 5.22 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
DATABASE API DOCUMENTATION
FOR THE
EVENT HANDLER APP
###########################
# Created by #
# Malcolm Geldmacher #
# For #
# Vient Apps #
###########################
TABLE OF CONTENTS:
1. Flow Diagram
2. Standardization
3. List of available Functions
4. Definitions of available Functions
##############################
# CHAPTER 1 #
# FLOW DIAGRAM #
##############################
The flow of code is as follows:
----------------------------------------------------------------------------
On app creation, a global db object is created
|
V
User completes action in app that requires db crud
|
V
Event handler code for action calls appropriate method of global db object and passes any necessary parameters
|
V
db object method creates httprequest and calls appropriate url/php script with necessary url parameters
|
V
server php script uses url parameters to call the associated stored procedure from the server through phpmyadmin/mysqli functionality
|
V
stored procedure on server db executes with parameters and returns results to php script
|
V
php script interprets results and returns a json string as appropriate.
|
V
db object in app collects and objectifies the json string into the appropriate object and returns said object to the calling code.
---------------------------------------------------------------------------
##############################
# CHAPTER 2 #
# STANDARDIZATION #
##############################
In order to standardize all output from the httpRequests, the following standardization has been made:
All php scripts return the following JSON object:
{
response : (either "error", "failure", or "success"),
message : (message related to action performed and response),
result : [(array of result objects from the database if appropriate)]
}
##############################
# CHAPTER 3 #
# LIST OF #
# AVAILABLE FUNCTIONS #
##############################
Here is a list of all available functions. Please see Chapter 4 for more detailed information about each of these functions including return types, parameters, return codes, etc.
------------------------
login
getEventsByLocation
createEvent
##############################
# CHAPTER 4 #
# DEFINITIONS OF #
# AVAILABLE FUNCTIONS #
##############################
This chapter contains detailed definitions and specifications of how the available functions in chapter 3 work. Descriptions will include return values, expected parameters and any other pertinent information to programming with these funcitons.
The programmer should know that there is a dbErr variable of the Database class that will give added information about any unsuccessful attempts at any queries.Those values will be specific to the function being called.
*************
** login **
*************
DESCRIPTION:
The login function should be used when a user of the system is attempting to log in to their account. Using the results of the login function will allow the programmer to know if the login was successful or not and doubles as a getUser function on successful login.
PARAMETERS:
username: String
password: String
RETURN VALUES:
If the login is successful, meaning that a correct password was given with the corresponding username, a User object is returned from the login function populated with all the user information from the database, excluding the password.
When a login is unsuccessful, the login function returns nil.
DBERR CODES:
0: Successful login
1: Unsuccessful login(mismatched username/password combination)
2: Connection/Query error
***************************
** getEventsByLocation **
***************************
DESCRIPTION:
The getEventsByLocation function returns an array of Event objects that are located within a specified range in miles given a specific location.
PARAMETERS:
location: Location
range: Double
RETURN VALUES:
If there are no query errors or connection errors, the function returns an array of Event objects that are within the given range of the specified location.
In the case of some error, the function returns nil.
DBERR CODES:
0: Successful query
1: N/A
2: Connection/Query error
*******************
** createEvent **
*******************
DESCRIPTION:
The createEvent function creates an Event with the given parameters and stores it in the database.
PARAMETERS:
userId: Int
title: String
description: String
date: DateTime
duration: Int
location: Location
private: Bool
maxAttendance: Int
minRating: Double
RETURN VALUES:
The function returns a fully populated Event object in the case of a successful Event creation/storage in the database.
In the case of some error, the function returns nil.
DBERR CODES:
0: Successful query
1: N/A
2: Connection/Query error