@itutoring/itutoring_application_js_api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CookiesManager.js +34 -0
- package/README.md +1 -0
- package/apiController.js +227 -0
- package/cache.js +19 -0
- package/index.js +2 -0
- package/modules/CoursesSystem.js +209 -0
- package/modules/CustomerAuth.js +76 -0
- package/modules/CustomerPortal.js +38 -0
- package/modules/Email.js +63 -0
- package/modules/Newsletters.js +22 -0
- package/modules/Payments.js +52 -0
- package/modules/ReservationSystem.js +238 -0
- package/modules/SubjectManager.js +112 -0
- package/modules/TeacherAuth.js +75 -0
- package/modules/TeacherManager.js +72 -0
- package/modules/TeacherPortal.js +208 -0
- package/modules/TeacherProfiles.js +47 -0
- package/objects/Course.js +26 -0
- package/objects/CourseReservation.js +10 -0
- package/objects/Customer.js +9 -0
- package/objects/Enums.js +38 -0
- package/objects/Reservation.js +28 -0
- package/objects/Subject.js +16 -0
- package/objects/Teacher.js +12 -0
- package/objects/TeacherProfile.js +8 -0
- package/package.json +22 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
|
|
3
|
+
class Payments
|
|
4
|
+
{
|
|
5
|
+
/**
|
|
6
|
+
* Respective module name for this class
|
|
7
|
+
*/
|
|
8
|
+
static #MODULE = "Payments";
|
|
9
|
+
|
|
10
|
+
// All method names
|
|
11
|
+
static #PURCHASE = "Purchase";
|
|
12
|
+
static #VALIDATE_PURCHASE = "ValidatePurchase";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Purchase specific product. After calling you'll be redirected depending on the result to success or cancel (failed) url
|
|
16
|
+
* @param {*} product product name as defined in php such as HOUR_LESSON
|
|
17
|
+
* @param {*} type payment type (credits, card), use PaymentType enum
|
|
18
|
+
* @param {*} successUrl
|
|
19
|
+
* @param {*} cancelUrl
|
|
20
|
+
* @param {*} successUrlParams additional query string to success url - optional
|
|
21
|
+
* @returns if stripe payment; returns stripe page url
|
|
22
|
+
*/
|
|
23
|
+
static async Purchase(product, isSaled, type, successUrl, cancelUrl, successUrlParams = "")
|
|
24
|
+
{
|
|
25
|
+
var url = await APIController.Post(this.#MODULE, this.#PURCHASE, {
|
|
26
|
+
'product': product,
|
|
27
|
+
'saled': APIController.BoolToInt(isSaled),
|
|
28
|
+
'type': type,
|
|
29
|
+
'successUrl': successUrl,
|
|
30
|
+
'cancelUrl': cancelUrl,
|
|
31
|
+
'successUrlParams': successUrlParams,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return url;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Call on success page after purchase to mark the payment as successful.
|
|
39
|
+
*
|
|
40
|
+
* Will return false if is already marked.
|
|
41
|
+
* @param {*} id
|
|
42
|
+
* @returns bool
|
|
43
|
+
*/
|
|
44
|
+
static async ValidatePurchase(transactionId)
|
|
45
|
+
{
|
|
46
|
+
var res = await APIController.Get(this.#MODULE, this.#VALIDATE_PURCHASE, { 'id': transactionId });
|
|
47
|
+
|
|
48
|
+
return APIController.IntToBool(res);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Payments;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
import Reservation from "./../objects/Reservation";
|
|
3
|
+
|
|
4
|
+
class ReservationSystem
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Respective module name for this class
|
|
8
|
+
*/
|
|
9
|
+
static #MODULE = "ReservationSystem";
|
|
10
|
+
|
|
11
|
+
// All method names
|
|
12
|
+
static #GET_AVAILABILITY_FOR_DAY = "GetAvailabilityForDay";
|
|
13
|
+
static #GET_AVAILABILITY_FOR_MONTH = "GetAvailabilityForMonth";
|
|
14
|
+
static #IS_TIME_AVAILABLE = "IsTimeAvailable";
|
|
15
|
+
static #IS_DAY_AVAILABLE = "IsDayAvailable";
|
|
16
|
+
static #RESERVE_TIME = "ReserveTime";
|
|
17
|
+
static #BOOK = "Book";
|
|
18
|
+
static #ORDER_TIMEOUT = "OrderTimeout";
|
|
19
|
+
static #CONFIRM_RESERVATION = "ConfirmReservation";
|
|
20
|
+
static #GET_RESERVATION = "GetReservation";
|
|
21
|
+
static #IS_RESERVATION_PAID = "IsReservationPaid";
|
|
22
|
+
static #MARK_RESERVATION_PAID = "MarkReservationPaid";
|
|
23
|
+
static #RETRIVE_ORDER_ID = "RetriveOrderID";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns availability for specific day and subject
|
|
27
|
+
* @param {*} date
|
|
28
|
+
* @param {*} subject
|
|
29
|
+
* @returns float in range 0...1
|
|
30
|
+
*/
|
|
31
|
+
static async GetAvailabilityForDay(date, subject)
|
|
32
|
+
{
|
|
33
|
+
var data = await APIController.Get(this.#MODULE, this.#GET_AVAILABILITY_FOR_DAY, { 'date': date, 'subject': subject });
|
|
34
|
+
|
|
35
|
+
return parseFloat(data);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get how much each day in month is free.
|
|
40
|
+
*
|
|
41
|
+
* @param {*} month month id (starts with 0 ends 11)
|
|
42
|
+
* @param {*} year
|
|
43
|
+
* @param {*} subject subject id
|
|
44
|
+
* @returns all values (in percent 0...1) by day ascending (1st .... 31st/30rd) as JSON string.
|
|
45
|
+
*/
|
|
46
|
+
static async GetAvailabilityForMonth(month, year, subject)
|
|
47
|
+
{
|
|
48
|
+
var data = await APIController.Get(this.#MODULE, this.#GET_AVAILABILITY_FOR_MONTH,
|
|
49
|
+
{
|
|
50
|
+
'month': month,
|
|
51
|
+
'year': year,
|
|
52
|
+
'subject': subject,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return JSON.parse(data);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Check if specific start time is availiable.
|
|
60
|
+
* @param {*} date
|
|
61
|
+
* @param {*} subject
|
|
62
|
+
* @param {*} startTime
|
|
63
|
+
* @param {*} lessons number of lessons (1 = 60 mins, 2 = 2x60 mins)
|
|
64
|
+
* @returns bool
|
|
65
|
+
*/
|
|
66
|
+
static async IsTimeAvailable(date, subject, startTime, lessons = 1)
|
|
67
|
+
{
|
|
68
|
+
var data = await APIController.Get(this.#MODULE, this.#IS_TIME_AVAILABLE, { 'date': date, 'subject': subject, 'start': startTime, "lessons": lessons });
|
|
69
|
+
|
|
70
|
+
return APIController.IntToBool(data);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get all available times for specific day and subject
|
|
75
|
+
* @param {*} date
|
|
76
|
+
* @param {*} subject
|
|
77
|
+
* @param {*} lessons number of lessons (1 = 60 mins, 2 = 2x60 mins)
|
|
78
|
+
* @returns float array of available times
|
|
79
|
+
*/
|
|
80
|
+
static async IsDayAvailable(date, subject, lessons = 1)
|
|
81
|
+
{
|
|
82
|
+
var availableTimes = await APIController.Get(this.#MODULE, this.#IS_DAY_AVAILABLE, { 'date': date, 'subject': subject, "lessons": lessons });
|
|
83
|
+
|
|
84
|
+
return JSON.parse(availableTimes);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Reserve time during creating order.
|
|
89
|
+
*
|
|
90
|
+
* Reserved time will have unique token.
|
|
91
|
+
*
|
|
92
|
+
* Is not needed to pass teacherId if you already calld GetTeacherForLesson. So teacher is already chosen and saved in session.
|
|
93
|
+
* @param {*} date
|
|
94
|
+
* @param {*} startTime
|
|
95
|
+
* @param {*} subject
|
|
96
|
+
* @param {*} lessons
|
|
97
|
+
* @param {*} teacherId
|
|
98
|
+
*/
|
|
99
|
+
static async ReserveTime(date, startTime, subject, lessons, teacherId = "session")
|
|
100
|
+
{
|
|
101
|
+
var result = await APIController.Get(this.#MODULE, this.#RESERVE_TIME, {
|
|
102
|
+
'date': date,
|
|
103
|
+
'start': startTime,
|
|
104
|
+
'subject': subject,
|
|
105
|
+
'lessons': lessons,
|
|
106
|
+
'teacher': teacherId,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return parseInt(result);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Keep teacherId in reservation object null if you chosen teacher before
|
|
114
|
+
* @param {*} reservation
|
|
115
|
+
* @param {*} lessons
|
|
116
|
+
* @returns int (BookReturn)
|
|
117
|
+
*/
|
|
118
|
+
static async Book(reservation, lessons)
|
|
119
|
+
{
|
|
120
|
+
if (!reservation.IsValid())
|
|
121
|
+
{
|
|
122
|
+
throw ("Reservation is not valid");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var reservationJSON = JSON.stringify(reservation);
|
|
126
|
+
|
|
127
|
+
var result = await APIController.Post(this.#MODULE, this.#BOOK, {
|
|
128
|
+
'reservation': encodeURIComponent(reservationJSON),
|
|
129
|
+
'lessons': lessons,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Return if reserved time in DB is still present.
|
|
137
|
+
*
|
|
138
|
+
* Need to be called after reserving time, so token is generated.
|
|
139
|
+
*
|
|
140
|
+
* Should be called before book to check that time.
|
|
141
|
+
* @returns true if is timeouted(time is deleted) , false if time is still there
|
|
142
|
+
*/
|
|
143
|
+
static async OrderTimeout()
|
|
144
|
+
{
|
|
145
|
+
var res = await APIController.Get(this.#MODULE, this.#ORDER_TIMEOUT);
|
|
146
|
+
|
|
147
|
+
return APIController.IntToBool(res);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Send confirmation email to teacher and customer.
|
|
152
|
+
* @param {*} resend If true, the last send confirmation email will be resend. (just for the same session)
|
|
153
|
+
* @returns True if succeded
|
|
154
|
+
*/
|
|
155
|
+
static async ConfirmReservation(resend = false)
|
|
156
|
+
{
|
|
157
|
+
var res = await APIController.Get(this.#MODULE, this.#CONFIRM_RESERVATION, { 'resend': APIController.BoolToInt(resend) });
|
|
158
|
+
|
|
159
|
+
return APIController.IntToBool(res);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Get reservation by id
|
|
164
|
+
* @param {*} id reservation id
|
|
165
|
+
* @returns Reservation object
|
|
166
|
+
*/
|
|
167
|
+
static async GetReservation(id)
|
|
168
|
+
{
|
|
169
|
+
var res = await APIController.Get(this.#MODULE, this.#GET_RESERVATION, { 'id': id });
|
|
170
|
+
|
|
171
|
+
try
|
|
172
|
+
{
|
|
173
|
+
JSON.parse(res)
|
|
174
|
+
}
|
|
175
|
+
catch
|
|
176
|
+
{
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var reservationArray = JSON.parse(res);
|
|
181
|
+
|
|
182
|
+
var reservation = new Reservation();
|
|
183
|
+
reservation.Date = reservationArray['Date'];
|
|
184
|
+
reservation.StartTime = reservationArray['StartTime'];
|
|
185
|
+
reservation.Subject = reservationArray['Subject'];
|
|
186
|
+
reservation.TeacherId = reservationArray['TeacherId'];
|
|
187
|
+
reservation.Note = reservationArray['Note'];
|
|
188
|
+
reservation.FirstName = reservationArray['FirstName'];
|
|
189
|
+
reservation.LastName = reservationArray['LastName'];
|
|
190
|
+
reservation.Email = reservationArray['Email'];
|
|
191
|
+
|
|
192
|
+
return reservation;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Check if reservation has been paid
|
|
197
|
+
* @param {*} id reservation id
|
|
198
|
+
* @returns
|
|
199
|
+
*/ Bool
|
|
200
|
+
static async IsReservationPaid(id)
|
|
201
|
+
{
|
|
202
|
+
var res = await APIController.Get(this.#MODULE, this.#IS_RESERVATION_PAID, { 'id': id })
|
|
203
|
+
|
|
204
|
+
return APIController.IntToBool(res);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Will mark reservation as paid. Must provide transaction id for that reservation to confirm that it was paid.
|
|
209
|
+
* @param {*} reservationId
|
|
210
|
+
* @param {*} transactionId
|
|
211
|
+
* @returns bool
|
|
212
|
+
*/
|
|
213
|
+
static async MarkReservationPaid(reservationId, transactionId)
|
|
214
|
+
{
|
|
215
|
+
var res = await APIController.Get(this.#MODULE, this.#MARK_RESERVATION_PAID, {
|
|
216
|
+
'reservationId': reservationId,
|
|
217
|
+
'transactionId': transactionId,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return APIController.IntToBool(res);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Get latest order id. Works for both Lessons and courses.
|
|
225
|
+
*
|
|
226
|
+
* Book function must be called before. ID is stored in session.
|
|
227
|
+
*
|
|
228
|
+
* @returns orderId
|
|
229
|
+
*/
|
|
230
|
+
static async RetriveOrderID()
|
|
231
|
+
{
|
|
232
|
+
var id = await APIController.Get(this.#MODULE, this.#RETRIVE_ORDER_ID);
|
|
233
|
+
|
|
234
|
+
return id;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default ReservationSystem;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import Subject from "./../objects/Subject";
|
|
2
|
+
import APIController from "./../apiController";
|
|
3
|
+
import Course from "./../objects/Course";
|
|
4
|
+
|
|
5
|
+
class SubjectManager
|
|
6
|
+
{
|
|
7
|
+
/**
|
|
8
|
+
* Respective module name for this class
|
|
9
|
+
*/
|
|
10
|
+
static #MODULE = "SubjectManager";
|
|
11
|
+
|
|
12
|
+
// All method names
|
|
13
|
+
static #GET_ALL_AVAILABLE_SUBJECTS = "GetAllAvailableSubjects";
|
|
14
|
+
static #GET_ALL_AVAILABLE_COURSES = "GetAllAvailableCourses";
|
|
15
|
+
|
|
16
|
+
// Cache keys
|
|
17
|
+
static #SUBJECTS_CACHE_KEY = "json_subjects_c_k";
|
|
18
|
+
static #COURSES_CACHE_KEY = "json_courses_c_k";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @returns Array (Subject[id]) of all available subjects as array of Subject objects. Key is id of subject.
|
|
23
|
+
*/
|
|
24
|
+
static async GetAllAvailableSubjects(requestReload = false)
|
|
25
|
+
{
|
|
26
|
+
var data;
|
|
27
|
+
|
|
28
|
+
/*if (APICache.IsCached(this.#SUBJECTS_CACHE_KEY) && !requestReload)
|
|
29
|
+
{
|
|
30
|
+
data = APICache.Retrive(this.#SUBJECTS_CACHE_KEY);
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
{
|
|
34
|
+
data = await APIController.Get(this.#MODULE, this.#GET_ALL_AVAILABLE_SUBJECTS);
|
|
35
|
+
APICache.Cache(this.#SUBJECTS_CACHE_KEY, data);
|
|
36
|
+
}*/
|
|
37
|
+
|
|
38
|
+
data = await APIController.Get(this.#MODULE, this.#GET_ALL_AVAILABLE_SUBJECTS);
|
|
39
|
+
|
|
40
|
+
var dataArray = JSON.parse(data);
|
|
41
|
+
|
|
42
|
+
var availableSubjects = [];
|
|
43
|
+
|
|
44
|
+
for (const [key, value] of Object.entries(dataArray))
|
|
45
|
+
{
|
|
46
|
+
var subject = new Subject();
|
|
47
|
+
subject.CreditPrice = value['CreditPrice'];
|
|
48
|
+
subject.Description = value['Description'];
|
|
49
|
+
subject.ID = value['ID'];
|
|
50
|
+
subject.IconPath = value['IconPath'];
|
|
51
|
+
subject.Name = value['Name'];
|
|
52
|
+
subject.Price = value['Price'];
|
|
53
|
+
subject.NameRaw = value['NameRaw'];
|
|
54
|
+
subject.Level = value['Level'];
|
|
55
|
+
subject.Item = value['Item'];
|
|
56
|
+
subject.PriceBeforeSale = value['PriceBeforeSale'];
|
|
57
|
+
subject.IsSaled = value['IsSaled'];
|
|
58
|
+
|
|
59
|
+
availableSubjects[subject.ID] = subject;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return availableSubjects;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static async GetAllAvailableCourses(requestReload = false)
|
|
66
|
+
{
|
|
67
|
+
var data;
|
|
68
|
+
|
|
69
|
+
/*if (APICache.IsCached(this.#COURSES_CACHE_KEY) && !requestReload)
|
|
70
|
+
{
|
|
71
|
+
data = APICache.Retrive(this.#COURSES_CACHE_KEY);
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
{
|
|
75
|
+
data = await APIController.Get(this.#MODULE, this.#GET_ALL_AVAILABLE_COURSES);
|
|
76
|
+
APICache.Cache(this.#COURSES_CACHE_KEY, data);
|
|
77
|
+
}*/
|
|
78
|
+
|
|
79
|
+
data = await APIController.Get(this.#MODULE, this.#GET_ALL_AVAILABLE_COURSES);
|
|
80
|
+
|
|
81
|
+
var dataArray = JSON.parse(data);
|
|
82
|
+
|
|
83
|
+
var availableCourses = [];
|
|
84
|
+
|
|
85
|
+
for (const [key, value] of Object.entries(dataArray))
|
|
86
|
+
{
|
|
87
|
+
var course = new Course();
|
|
88
|
+
|
|
89
|
+
course.Name = value['Name'];
|
|
90
|
+
course.NameRaw = value['NameRaw'];
|
|
91
|
+
course.School = value['School'];
|
|
92
|
+
course.Price = value['Price'];
|
|
93
|
+
course.CreditPrice = value['CreditPrice'];
|
|
94
|
+
course.ID = value['ID'];
|
|
95
|
+
course.Day = value['Day'];
|
|
96
|
+
course.Time = value['Time'];
|
|
97
|
+
course.Length = value['Length'];
|
|
98
|
+
course.Lessons = value['Lessons'];
|
|
99
|
+
course.Capacity = value['Capacity'];
|
|
100
|
+
course.Item = value['Item'];
|
|
101
|
+
course.Subject = value['Subject'];
|
|
102
|
+
course.PriceBeforeSale = value['PriceBeforeSale'];
|
|
103
|
+
course.IsSaled = value['IsSaled'];
|
|
104
|
+
|
|
105
|
+
availableCourses[course.ID] = course;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return availableCourses;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default SubjectManager;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
|
|
3
|
+
class TeacherAuth
|
|
4
|
+
{
|
|
5
|
+
/**
|
|
6
|
+
* Respective module name for this class
|
|
7
|
+
*/
|
|
8
|
+
static #MODULE = "TeacherAuth";
|
|
9
|
+
|
|
10
|
+
// All method names
|
|
11
|
+
static #LOGIN = "Login";
|
|
12
|
+
static #REGISTER = "Register";
|
|
13
|
+
static #IS_AUTHENTICATED = "IsAuthenticated";
|
|
14
|
+
static #CHANGE_PASSWOD = "ChangePassword";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {*} email
|
|
19
|
+
* @param {*} password
|
|
20
|
+
* @returns int (AuthResult)
|
|
21
|
+
*/
|
|
22
|
+
static async Login(email, password)
|
|
23
|
+
{
|
|
24
|
+
var res = await APIController.Post(this.#MODULE, this.#LOGIN, {
|
|
25
|
+
'email': email,
|
|
26
|
+
'pass': password,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Change current password
|
|
34
|
+
* @param {*} oldPass is required to authorize user
|
|
35
|
+
* @param {*} newPass
|
|
36
|
+
* @returns int (PasswordChange enum)
|
|
37
|
+
*/
|
|
38
|
+
static async ChangePassword(oldPass, newPass)
|
|
39
|
+
{
|
|
40
|
+
var res = await APIController.Post(this.#MODULE, this.#CHANGE_PASSWOD, {
|
|
41
|
+
'oldPass': oldPass,
|
|
42
|
+
'newPass': newPass,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {*} email
|
|
51
|
+
* @param {*} password
|
|
52
|
+
* @returns int (AuthResult)
|
|
53
|
+
*/
|
|
54
|
+
static async Register(email, password, name, meetingLink, subjects)
|
|
55
|
+
{
|
|
56
|
+
var res = await APIController.Post(this.#MODULE, this.#REGISTER, {
|
|
57
|
+
'email': email,
|
|
58
|
+
'pass': password,
|
|
59
|
+
'name': name,
|
|
60
|
+
'meetingLink': meetingLink,
|
|
61
|
+
'subjects': subjects,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return res;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static async IsAuthenticated()
|
|
68
|
+
{
|
|
69
|
+
var res = await APIController.Get(this.#MODULE, this.#IS_AUTHENTICATED);
|
|
70
|
+
|
|
71
|
+
return APIController.IntToBool(res);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default TeacherAuth;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
import Teacher from "./../objects/Teacher";
|
|
3
|
+
|
|
4
|
+
class TeacherManager
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* Respective module name for this class
|
|
8
|
+
*/
|
|
9
|
+
static #MODULE = "TeacherManager";
|
|
10
|
+
|
|
11
|
+
// All method names
|
|
12
|
+
static #GET_TEACHER_FOR_LESSON = "GetTeacherForLesson";
|
|
13
|
+
static #GET_ALL_TEACHERS = "GetAllTeachers";
|
|
14
|
+
static #UPDATE_SUBJECT_TIMES = "UpdateSubjectTimes";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Find and choose available teacher for your time.
|
|
18
|
+
* Teacher will be stored in session on server.
|
|
19
|
+
* @param {*} date
|
|
20
|
+
* @param {*} startTime
|
|
21
|
+
* @param {*} subject
|
|
22
|
+
* @param {*} lessons
|
|
23
|
+
* @returns true if teacher was found, false if no teacher available
|
|
24
|
+
*/
|
|
25
|
+
static async GetTeacherForLesson(date, startTime, subject, lessons)
|
|
26
|
+
{
|
|
27
|
+
var result = await APIController.Get(this.#MODULE, this.#GET_TEACHER_FOR_LESSON, {
|
|
28
|
+
'date': date,
|
|
29
|
+
'start': startTime,
|
|
30
|
+
'subject': subject,
|
|
31
|
+
'lessons': lessons,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return APIController.IntToBool(result);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static async GetAllTeachers()
|
|
38
|
+
{
|
|
39
|
+
var teachers = await APIController.Get(this.#MODULE, this.#GET_ALL_TEACHERS);
|
|
40
|
+
|
|
41
|
+
var teachersArray = JSON.parse(teachers);
|
|
42
|
+
|
|
43
|
+
var teachersClasses = [];
|
|
44
|
+
|
|
45
|
+
for (const[key, value] of Object.entries(teachersArray))
|
|
46
|
+
{
|
|
47
|
+
var teacher = new Teacher;
|
|
48
|
+
|
|
49
|
+
teacher.Name = value['Name'];
|
|
50
|
+
teacher.Email = value['Email'];
|
|
51
|
+
teacher.ZoomMeeting = value['ZoomMeeting'];
|
|
52
|
+
teacher.ID = value['ID'];
|
|
53
|
+
teacher.TeachedLessons = value['TeachedLessons'];
|
|
54
|
+
teacher.Admin = APIController.IntToBool(value['Admin']);
|
|
55
|
+
|
|
56
|
+
teachersClasses[teacher.ID] = teacher;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return teachersClasses;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static async UpdateSubjectTimes(teacherId)
|
|
63
|
+
{
|
|
64
|
+
var res = await APIController.Get(this.#MODULE, this.#UPDATE_SUBJECT_TIMES, {
|
|
65
|
+
'teacherId': teacherId,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return APIController.IntToBool(res);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default TeacherManager;
|