@itutoring/itutoring_application_js_api 1.0.14 → 1.0.16
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/apiController.js +21 -5
- package/modules/TeacherManager.js +8 -0
- package/objects/Teacher.js +1 -0
- package/package.json +1 -1
package/apiController.js
CHANGED
|
@@ -10,17 +10,18 @@ class APIController
|
|
|
10
10
|
static #CLIENT_KEY = "-1";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* R_KEY MUST be loaded before calling this method!
|
|
14
14
|
* @returns Returns apropriate rest url based on current server.
|
|
15
15
|
*/
|
|
16
16
|
static REST_URL()
|
|
17
17
|
{
|
|
18
|
-
if (location.hostname == 'localhost')
|
|
18
|
+
if (location.hostname == 'localhost' || this.#R_KEY == R_KEYs.r_key_test)
|
|
19
19
|
{
|
|
20
20
|
return "https://api.test.itutoring.cz/";
|
|
21
21
|
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
if (this.#R_KEY == R_KEYs.r_key_live)
|
|
24
25
|
{
|
|
25
26
|
return "https://api.itutoring.cz/";
|
|
26
27
|
}
|
|
@@ -84,7 +85,7 @@ class APIController
|
|
|
84
85
|
* @param data "data must be as array - key, value pair. They'll be passed into the request"
|
|
85
86
|
* @returns "Response from server"
|
|
86
87
|
*/
|
|
87
|
-
static async Post(module, method, data)
|
|
88
|
+
static async Post(module, method, data, file = null)
|
|
88
89
|
{
|
|
89
90
|
await APIController.GetLocalRKey();
|
|
90
91
|
await APIController.GetClientKey();
|
|
@@ -109,7 +110,22 @@ class APIController
|
|
|
109
110
|
request.setRequestHeader("sites", location.hostname);
|
|
110
111
|
request.setRequestHeader("key", APIController.#CLIENT_KEY);
|
|
111
112
|
request.setRequestHeader("visitor-session", this.GetVisitorSessionID());
|
|
112
|
-
|
|
113
|
+
|
|
114
|
+
if (file != null)
|
|
115
|
+
{
|
|
116
|
+
var formData = new FormData();
|
|
117
|
+
formData.append("file", file);
|
|
118
|
+
for (const [key, value] of Object.entries(data))
|
|
119
|
+
{
|
|
120
|
+
formData.append(key, value);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
request.send(formData);
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
{
|
|
127
|
+
request.send(args);
|
|
128
|
+
}
|
|
113
129
|
});
|
|
114
130
|
}
|
|
115
131
|
|
|
@@ -12,6 +12,7 @@ class TeacherManager
|
|
|
12
12
|
static #GET_TEACHER_FOR_LESSON = "GetTeacherForLesson";
|
|
13
13
|
static #GET_ALL_TEACHERS = "GetAllTeachers";
|
|
14
14
|
static #UPDATE_SUBJECT_TIMES = "UpdateSubjectTimes";
|
|
15
|
+
static #UPDATE_PHOTO = "UpdatePhoto";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Find and choose available teacher for your time.
|
|
@@ -67,6 +68,13 @@ class TeacherManager
|
|
|
67
68
|
|
|
68
69
|
return APIController.IntToBool(res);
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
static async UpdatePhoto(teacherId, photoFile)
|
|
73
|
+
{
|
|
74
|
+
var res = await APIController.Post(this.#MODULE, this.#UPDATE_PHOTO, {
|
|
75
|
+
"id": teacherId,
|
|
76
|
+
}, photoFile);
|
|
77
|
+
}
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
export default TeacherManager;
|
package/objects/Teacher.js
CHANGED