@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,208 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
import Reservation from "./../objects/Reservation";
|
|
3
|
+
import Teacher from "./../objects/Teacher";
|
|
4
|
+
|
|
5
|
+
class TeacherPortal
|
|
6
|
+
{
|
|
7
|
+
/**
|
|
8
|
+
* Respective module name for this class
|
|
9
|
+
*/
|
|
10
|
+
static #MODULE = "TeacherPortal";
|
|
11
|
+
|
|
12
|
+
// All method names
|
|
13
|
+
static #REMOVE_PERIODIC_TIME = "RemovePeriodicTime";
|
|
14
|
+
static #REMOVE_TIMES = "RemoveTimes";
|
|
15
|
+
static #SELECT_TIMES = "SelectTimes";
|
|
16
|
+
static #SET_TIMES_PERIODICLY = "SetTimePeriodicly";
|
|
17
|
+
static #GET_SUBJECTS = "GetSubjects";
|
|
18
|
+
static #GET_DATE_TIMES = "GetDayTimes";
|
|
19
|
+
static #GET_TEACHER_INFO = "GetTeacherInfo";
|
|
20
|
+
static #GET_RESERVATIONS = "GetReservations";
|
|
21
|
+
static #SET_BITMOJI = "SetBitmoji";
|
|
22
|
+
static #HAS_BITMOJI = "HasBitmoji";
|
|
23
|
+
|
|
24
|
+
static async HasBitmoji()
|
|
25
|
+
{
|
|
26
|
+
var res = await APIController.Get(this.#MODULE, this.#HAS_BITMOJI);
|
|
27
|
+
|
|
28
|
+
return APIController.IntToBool(res);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static async SetBitmoji(url)
|
|
32
|
+
{
|
|
33
|
+
await APIController.Get(this.#MODULE, this.#SET_BITMOJI, {
|
|
34
|
+
'url': encodeURIComponent(url),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Removes time for specific date and following weeks
|
|
42
|
+
* @param {*} from start time
|
|
43
|
+
* @param {*} to end time
|
|
44
|
+
* @param {*} date
|
|
45
|
+
* @param {*} subject array of subjects
|
|
46
|
+
* @param {*} period how many weeks from date (is treated as start date) will be affected
|
|
47
|
+
*/
|
|
48
|
+
static async RemovePeriodicTime(from, to, date, subject, period)
|
|
49
|
+
{
|
|
50
|
+
var subjects = JSON.stringify(subject);
|
|
51
|
+
|
|
52
|
+
await APIController.Post(this.#MODULE, this.#REMOVE_PERIODIC_TIME, {
|
|
53
|
+
'from': from,
|
|
54
|
+
'to': to,
|
|
55
|
+
'date': date,
|
|
56
|
+
'subject': encodeURIComponent(subjects),
|
|
57
|
+
'period': period,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static async GetReservations()
|
|
62
|
+
{
|
|
63
|
+
var data = await APIController.Get(this.#MODULE, this.#GET_RESERVATIONS);
|
|
64
|
+
|
|
65
|
+
try
|
|
66
|
+
{
|
|
67
|
+
JSON.parse(data);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var array = JSON.parse(data);
|
|
74
|
+
var reservations = [];
|
|
75
|
+
|
|
76
|
+
for (const [key, value] of Object.entries(array))
|
|
77
|
+
{
|
|
78
|
+
var reservation = new Reservation();
|
|
79
|
+
|
|
80
|
+
reservation.Date = value['Date']
|
|
81
|
+
reservation.StartTime = value['StartTime'];
|
|
82
|
+
reservation.Subject = value['Subject'];
|
|
83
|
+
reservation.TeacherId = value['TeacherId'];
|
|
84
|
+
reservation.Note = value['Note'];
|
|
85
|
+
reservation.FirstName = value['FirstName'];
|
|
86
|
+
reservation.LastName = value['LastName'];
|
|
87
|
+
reservation.Email = value['Email'];
|
|
88
|
+
reservation.ID = value['ID'];
|
|
89
|
+
|
|
90
|
+
reservations[key] = reservation;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return reservations;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* This method will return all availabe teacher info (Except password for security reasons).
|
|
98
|
+
*/
|
|
99
|
+
static async GetTeacherInfo()
|
|
100
|
+
{
|
|
101
|
+
var data = await APIController.Get(this.#MODULE, this.#GET_TEACHER_INFO);
|
|
102
|
+
|
|
103
|
+
try
|
|
104
|
+
{
|
|
105
|
+
JSON.parse(data);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var teacherArray = JSON.parse(data);
|
|
112
|
+
|
|
113
|
+
var teacher = new Teacher();
|
|
114
|
+
teacher.Email = teacherArray['Email'];
|
|
115
|
+
teacher.Name = teacherArray['Name'];
|
|
116
|
+
teacher.ZoomMeeting = teacherArray['ZoomMeeting'];
|
|
117
|
+
teacher.ID = teacherArray['ID'];
|
|
118
|
+
teacher.TeachedLessons = teacherArray['TeachedLessons'];
|
|
119
|
+
teacher.Admin = teacherArray['Admin'];
|
|
120
|
+
teacher.BitmojiURL =decodeURIComponent(teacherArray['BitmojiURL']);
|
|
121
|
+
|
|
122
|
+
return teacher;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* @param {*} from
|
|
128
|
+
* @param {*} to
|
|
129
|
+
* @param {*} date
|
|
130
|
+
* @param {*} subject array of subjects
|
|
131
|
+
*/
|
|
132
|
+
static async RemoveTimes(from, to, date, subject)
|
|
133
|
+
{
|
|
134
|
+
var subjects = JSON.stringify(subject);
|
|
135
|
+
|
|
136
|
+
await APIController.Post(this.#MODULE, this.#REMOVE_TIMES, {
|
|
137
|
+
'from': from,
|
|
138
|
+
'to': to,
|
|
139
|
+
'date': date,
|
|
140
|
+
'subject': encodeURIComponent(subjects),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @param {*} from
|
|
147
|
+
* @param {*} to
|
|
148
|
+
* @param {*} date
|
|
149
|
+
* @param {*} subject array of subjects
|
|
150
|
+
*/
|
|
151
|
+
static async SelectTimes(from, to, date, subject)
|
|
152
|
+
{
|
|
153
|
+
var subjects = JSON.stringify(subject);
|
|
154
|
+
|
|
155
|
+
await APIController.Post(this.#MODULE, this.#SELECT_TIMES, {
|
|
156
|
+
'from': from,
|
|
157
|
+
'to': to,
|
|
158
|
+
'date': date,
|
|
159
|
+
'subject': encodeURIComponent(subjects),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Set time for specific date and following weeks
|
|
165
|
+
* @param {*} from
|
|
166
|
+
* @param {*} to
|
|
167
|
+
* @param {*} date
|
|
168
|
+
* @param {*} subject array of subjects
|
|
169
|
+
* @param {*} period how many weeks from date (is treated as start date) will be affected
|
|
170
|
+
*/
|
|
171
|
+
static async SetTimePeriodicly(from, to, date, subject, period)
|
|
172
|
+
{
|
|
173
|
+
var subjects = JSON.stringify(subject);
|
|
174
|
+
|
|
175
|
+
await APIController.Post(this.#MODULE, this.#SET_TIMES_PERIODICLY, {
|
|
176
|
+
'from': from,
|
|
177
|
+
'to': to,
|
|
178
|
+
'date': date,
|
|
179
|
+
'subject': encodeURIComponent(subjects),
|
|
180
|
+
'period': period,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Gets all subjects this teacher can teach.
|
|
186
|
+
* @returns json object
|
|
187
|
+
*/
|
|
188
|
+
static async GetSubjects()
|
|
189
|
+
{
|
|
190
|
+
var res = await APIController.Get(this.#MODULE, this.#GET_SUBJECTS);
|
|
191
|
+
|
|
192
|
+
return JSON.parse(res);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Return all available times for this teacher for specific day
|
|
197
|
+
* @param {*} date
|
|
198
|
+
* @returns JSON object
|
|
199
|
+
*/
|
|
200
|
+
static async GetDayTimes(date, id = 'logged')
|
|
201
|
+
{
|
|
202
|
+
var res = await APIController.Get(this.#MODULE, this.#GET_DATE_TIMES, { 'date': date, 'id': id});
|
|
203
|
+
|
|
204
|
+
return JSON.parse(res);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export default TeacherPortal;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import APIController from "./../apiController";
|
|
2
|
+
import TeacherProfile from "./../objects/TeacherProfile";
|
|
3
|
+
|
|
4
|
+
class TeacherProfiles
|
|
5
|
+
{
|
|
6
|
+
static #MODULE = "TeacherProfiles";
|
|
7
|
+
|
|
8
|
+
static #GET_PROFILES = "GetProfiles";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Retrive all public teacher profiles
|
|
13
|
+
*
|
|
14
|
+
* @returns teachers public profiles as array
|
|
15
|
+
*/
|
|
16
|
+
static async GetProfiles()
|
|
17
|
+
{
|
|
18
|
+
var profiles = await APIController.Get(this.#MODULE, this.#GET_PROFILES);
|
|
19
|
+
|
|
20
|
+
var parsedProfiles;
|
|
21
|
+
try
|
|
22
|
+
{
|
|
23
|
+
parsedProfiles = JSON.parse(profiles);
|
|
24
|
+
}
|
|
25
|
+
catch
|
|
26
|
+
{
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var profilesArray = [];
|
|
31
|
+
|
|
32
|
+
for (const [key, value] of Object.entries(parsedProfiles))
|
|
33
|
+
{
|
|
34
|
+
var profile = new TeacherProfile();
|
|
35
|
+
|
|
36
|
+
profile.Name = value['Name'];
|
|
37
|
+
profile.Bio = value['Bio'];
|
|
38
|
+
profile.PhotoPath = value['PhotoPath'];
|
|
39
|
+
|
|
40
|
+
profilesArray[key] = profile;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return profilesArray;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default TeacherProfiles;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class Course
|
|
2
|
+
{
|
|
3
|
+
Name;
|
|
4
|
+
NameRaw;
|
|
5
|
+
School;
|
|
6
|
+
Price;
|
|
7
|
+
PriceBeforeSale = -1;
|
|
8
|
+
IsSaled = false;
|
|
9
|
+
CreditPrice;
|
|
10
|
+
ID;
|
|
11
|
+
Day;
|
|
12
|
+
/**
|
|
13
|
+
* as string in hh:mm
|
|
14
|
+
*/
|
|
15
|
+
Time;
|
|
16
|
+
Length;
|
|
17
|
+
/**
|
|
18
|
+
* Array of lesson dates as dd/mm/YYYY
|
|
19
|
+
*/
|
|
20
|
+
Lessons;
|
|
21
|
+
Capacity;
|
|
22
|
+
Item;
|
|
23
|
+
Subject;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default Course;
|
package/objects/Enums.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const BookReturn = {
|
|
2
|
+
SUCCESS: 0,
|
|
3
|
+
NO_TEACHER_AVAILABLE: 1,
|
|
4
|
+
ERROR: 2,
|
|
5
|
+
BAD_RESERVATION: 3,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const AuthResult = {
|
|
9
|
+
Authenticated: 0,
|
|
10
|
+
EmailUsed: 1,
|
|
11
|
+
ConnectionError: 2,
|
|
12
|
+
MissingInfo: 3,
|
|
13
|
+
WrongPassword: 4,
|
|
14
|
+
Error: 5,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const PaymentType = {
|
|
18
|
+
Stripe: 0,
|
|
19
|
+
Credits: 1,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DeviceOS = {
|
|
23
|
+
WindowsPhone: 0,
|
|
24
|
+
Android: 1,
|
|
25
|
+
iOS: 2,
|
|
26
|
+
Desktop: 3,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const PasswordChange = {
|
|
30
|
+
Changed: 0,
|
|
31
|
+
NotAuthenticated: 1,
|
|
32
|
+
NotAuthorized: 2,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const R_KEYs = {
|
|
36
|
+
r_key_test: 'r_key_test',
|
|
37
|
+
r_key_live: 'r_key_live'
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class Reservation
|
|
2
|
+
{
|
|
3
|
+
Date;
|
|
4
|
+
StartTime;
|
|
5
|
+
Subject;
|
|
6
|
+
TeacherId;
|
|
7
|
+
Note;
|
|
8
|
+
FirstName;
|
|
9
|
+
LastName;
|
|
10
|
+
Email;
|
|
11
|
+
ID;
|
|
12
|
+
|
|
13
|
+
IsValid()
|
|
14
|
+
{
|
|
15
|
+
if (this.Date == null ||
|
|
16
|
+
this.StartTime == null ||
|
|
17
|
+
this.Subject == null ||
|
|
18
|
+
this.Note == null ||
|
|
19
|
+
this.FirstName == null ||
|
|
20
|
+
this.LastName == null ||
|
|
21
|
+
this.Email == null)
|
|
22
|
+
return false;
|
|
23
|
+
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default Reservation;
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@itutoring/itutoring_application_js_api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Javascript API for iTutoring Application",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/iTutoring-s-r-o/iTutoring_Application_API-js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"api"
|
|
15
|
+
],
|
|
16
|
+
"author": "Tadeas Kaba",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/iTutoring-s-r-o/iTutoring_Application_API-js/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/iTutoring-s-r-o/iTutoring_Application_API-js#readme"
|
|
22
|
+
}
|