@itutoring/itutoring_application_js_api 1.5.23 → 1.6.1

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/index.d.ts CHANGED
@@ -5,7 +5,6 @@ declare module 'iTutoring Application JS API';
5
5
  import APIController from "./apiController";
6
6
  import CookiesManager from "./CookiesManager";
7
7
 
8
- import CoursesSystem from "./modules/CoursesSystem";
9
8
  import CustomerAuth from "./modules/CustomerAuth";
10
9
  import CustomerPortal from "./modules/CustomerPortal";
11
10
  import Email from "./modules/Email";
@@ -61,7 +60,6 @@ export
61
60
  APIController,
62
61
  CookiesManager,
63
62
 
64
- CoursesSystem,
65
63
  CustomerAuth,
66
64
  CustomerPortal,
67
65
  Email,
package/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  import APIController from "./apiController";
4
4
  import CookiesManager from "./CookiesManager";
5
5
 
6
- import CoursesSystem from "./modules/CoursesSystem";
7
6
  import CustomerAuth from "./modules/CustomerAuth";
8
7
  import CustomerPortal from "./modules/CustomerPortal";
9
8
  import Email from "./modules/Email";
@@ -59,7 +58,6 @@ export
59
58
  APIController,
60
59
  CookiesManager,
61
60
 
62
- CoursesSystem,
63
61
  CustomerAuth,
64
62
  CustomerPortal,
65
63
  Email,
@@ -9,21 +9,7 @@ class ReservationSystem
9
9
  */
10
10
  static #MODULE = "ReservationSystem";
11
11
 
12
- // All method names
13
- static #GET_AVAILABILITY_FOR_DAY = "GetAvailabilityForDay";
14
- static #GET_AVAILABILITY_FOR_MONTH = "GetAvailabilityForMonth";
15
- static #IS_TIME_AVAILABLE = "IsTimeAvailable";
16
- static #IS_DAY_AVAILABLE = "IsDayAvailable";
17
- static #RESERVE_TIME = "ReserveTime";
18
- static #BOOK = "Book";
19
- static #ORDER_TIMEOUT = "OrderTimeout";
20
- static #CONFIRM_RESERVATION = "ConfirmReservation";
21
- static #GET_RESERVATION = "GetReservation";
22
- static #IS_RESERVATION_PAID = "IsReservationPaid";
23
- static #MARK_RESERVATION_PAID = "MarkReservationPaid";
24
- static #RETRIVE_ORDER_ID = "RetriveOrderID";
25
12
  static #SEND_REQUEST = "SendRequest";
26
-
27
13
  static #ADD_ITEM_TO_CART = "AddItemToCart";
28
14
  static #GET_CART_ITEMS = "GetCartItems";
29
15
  static #GET_TOTAL_PRICE = "GetTotalPrice";
@@ -141,232 +127,6 @@ class ReservationSystem
141
127
  return amounts;
142
128
  }
143
129
 
144
-
145
- /**
146
- * Returns availability for specific day and subject
147
- * @param {*} date
148
- * @param {*} subject
149
- * @returns float in range 0...1
150
- * @deprecated
151
- */
152
- static async GetAvailabilityForDay(date, subject)
153
- {
154
- var data = await APIController.Get(this.#MODULE, this.#GET_AVAILABILITY_FOR_DAY, { 'date': date, 'subject': subject });
155
-
156
- return parseFloat(data);
157
- }
158
-
159
- /**
160
- * Get how much each day in month is free.
161
- *
162
- * @param {*} month month id (starts with 0 ends 11)
163
- * @param {*} year
164
- * @param {*} subject subject id
165
- * @returns all values (in percent 0...1) by day ascending (1st .... 31st/30rd) as JSON string.
166
- * @deprecated
167
- */
168
- static async GetAvailabilityForMonth(month, year, subject)
169
- {
170
- var data = await APIController.Get(this.#MODULE, this.#GET_AVAILABILITY_FOR_MONTH,
171
- {
172
- 'month': month,
173
- 'year': year,
174
- 'subject': subject,
175
- });
176
-
177
- return JSON.parse(data);
178
- }
179
-
180
- /**
181
- * Check if specific start time is availiable.
182
- * @param {*} date
183
- * @param {*} subject
184
- * @param {*} startTime
185
- * @param {*} lessons number of lessons (1 = 60 mins, 2 = 2x60 mins)
186
- * @returns bool
187
- * @deprecated
188
- */
189
- static async IsTimeAvailable(date, subject, startTime, lessons = 1)
190
- {
191
- var data = await APIController.Get(this.#MODULE, this.#IS_TIME_AVAILABLE, { 'date': date, 'subject': subject, 'start': startTime, "lessons": lessons });
192
-
193
- return APIController.IntToBool(data);
194
- }
195
-
196
- /**
197
- * Get all available times for specific day and subject
198
- * @param {*} date
199
- * @param {*} subject
200
- * @param {*} lessons number of lessons (1 = 60 mins, 2 = 2x60 mins)
201
- * @returns float array of available times
202
- * @deprecated
203
- */
204
- static async IsDayAvailable(date, subject, lessons = 1)
205
- {
206
- var availableTimes = await APIController.Get(this.#MODULE, this.#IS_DAY_AVAILABLE, { 'date': date, 'subject': subject, "lessons": lessons });
207
-
208
- return JSON.parse(availableTimes);
209
- }
210
-
211
- /**
212
- * Reserve time during creating order.
213
- *
214
- * Reserved time will have unique token.
215
- *
216
- * Is not needed to pass teacherId if you already calld GetTeacherForLesson. So teacher is already chosen and saved in session.
217
- * @param {*} date
218
- * @param {*} startTime
219
- * @param {*} subject
220
- * @param {*} lessons
221
- * @param {*} teacherId
222
- * @deprecated
223
- */
224
- static async ReserveTime(date, startTime, subject, lessons, teacherId = "session")
225
- {
226
- var result = await APIController.Get(this.#MODULE, this.#RESERVE_TIME, {
227
- 'date': date,
228
- 'start': startTime,
229
- 'subject': subject,
230
- 'lessons': lessons,
231
- 'teacher': teacherId,
232
- });
233
-
234
- return parseInt(result);
235
- }
236
-
237
- /**
238
- * Keep teacherId in reservation object null if you chosen teacher before
239
- * @param {*} reservation
240
- * @param {*} lessons
241
- * @returns int (BookReturn)
242
- * @deprecated
243
- */
244
- static async Book(reservation, lessons)
245
- {
246
- if (!reservation.IsValid())
247
- {
248
- throw ("Reservation is not valid");
249
- }
250
-
251
- var reservationJSON = JSON.stringify(reservation);
252
-
253
- var result = await APIController.Post(this.#MODULE, this.#BOOK, {
254
- 'reservation': encodeURIComponent(reservationJSON),
255
- 'lessons': lessons,
256
- });
257
-
258
- return result;
259
- }
260
-
261
- /**
262
- * Return if reserved time in DB is still present.
263
- *
264
- * Need to be called after reserving time, so token is generated.
265
- *
266
- * Should be called before book to check that time.
267
- * @returns true if is timeouted(time is deleted) , false if time is still there
268
- * @deprecated
269
- */
270
- static async OrderTimeout()
271
- {
272
- var res = await APIController.Get(this.#MODULE, this.#ORDER_TIMEOUT);
273
-
274
- return APIController.IntToBool(res);
275
- }
276
-
277
- /**
278
- * Send confirmation email to teacher and customer.
279
- * @param {*} resend If true, the last send confirmation email will be resend. (just for the same session)
280
- * @returns True if succeded
281
- * @deprecated
282
- */
283
- static async ConfirmReservation(resend = false)
284
- {
285
- var res = await APIController.Get(this.#MODULE, this.#CONFIRM_RESERVATION, { 'resend': APIController.BoolToInt(resend) });
286
-
287
- return APIController.IntToBool(res);
288
- }
289
-
290
- /**
291
- * Get reservation by id
292
- * @param {*} id reservation id
293
- * @returns Reservation object
294
- * @deprecated
295
- */
296
- static async GetReservation(id)
297
- {
298
- var res = await APIController.Get(this.#MODULE, this.#GET_RESERVATION, { 'id': id });
299
-
300
- try
301
- {
302
- JSON.parse(res)
303
- }
304
- catch
305
- {
306
- return null;
307
- }
308
-
309
- var reservationArray = JSON.parse(res);
310
-
311
- var reservation = new Reservation();
312
- reservation.Date = reservationArray['Date'];
313
- reservation.StartTime = reservationArray['StartTime'];
314
- reservation.Subject = reservationArray['Subject'];
315
- reservation.TeacherId = reservationArray['TeacherId'];
316
- reservation.Note = reservationArray['Note'];
317
- reservation.FirstName = reservationArray['FirstName'];
318
- reservation.LastName = reservationArray['LastName'];
319
- reservation.Email = reservationArray['Email'];
320
-
321
- return reservation;
322
- }
323
-
324
- /**
325
- * Check if reservation has been paid
326
- * @param {*} id reservation id
327
- * @returns
328
- * @deprecated
329
- */
330
- static async IsReservationPaid(id)
331
- {
332
- var res = await APIController.Get(this.#MODULE, this.#IS_RESERVATION_PAID, { 'id': id })
333
-
334
- return APIController.IntToBool(res);
335
- }
336
-
337
- /**
338
- * Will mark reservation as paid. Must provide transaction id for that reservation to confirm that it was paid.
339
- * @param {*} reservationId
340
- * @param {*} transactionId
341
- * @returns bool
342
- * @deprecated
343
- */
344
- static async MarkReservationPaid(reservationId, transactionId)
345
- {
346
- var res = await APIController.Get(this.#MODULE, this.#MARK_RESERVATION_PAID, {
347
- 'reservationId': reservationId,
348
- 'transactionId': transactionId,
349
- });
350
-
351
- return APIController.IntToBool(res);
352
- }
353
-
354
- /**
355
- * Get latest order id. Works for both Lessons and courses.
356
- *
357
- * Book function must be called before. ID is stored in session.
358
- *
359
- * @returns orderId
360
- *
361
- * @deprecated
362
- */
363
- static async RetriveOrderID()
364
- {
365
- var id = await APIController.Get(this.#MODULE, this.#RETRIVE_ORDER_ID);
366
-
367
- return id;
368
- }
369
-
370
130
  /**
371
131
  * Send request for tutoring. Will register as event
372
132
  * @param {*} name
package/objects/Course.js CHANGED
@@ -1,3 +1,7 @@
1
+
2
+ /**
3
+ * @deprecated do not use
4
+ */
1
5
  class Course
2
6
  {
3
7
  Name;
@@ -1,3 +1,7 @@
1
+
2
+ /**
3
+ * @deprecated do not use
4
+ */
1
5
  class CourseReservation
2
6
  {
3
7
  FirstName;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @deprecated do not use
3
+
4
+ */
1
5
  class Reservation
2
6
  {
3
7
  Date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itutoring/itutoring_application_js_api",
3
- "version": "1.5.23",
3
+ "version": "1.6.1",
4
4
  "description": "Javascript API for iTutoring Application",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,209 +0,0 @@
1
- import APIController from "./../apiController";
2
- import Course from "./../objects/Course";
3
- import CourseReservation from "../objects/CourseReservation";
4
-
5
- class CoursesSystem
6
- {
7
- /**
8
- * Respective module name for this class
9
- */
10
- static #MODULE = "CourseSystem";
11
-
12
- // All method names
13
- static #GET_ALL_AVAILABLE_COURSES = "GetAvailableCourses";
14
- static #GET_PRICE = "GetPrice";
15
- static #BOOK = "Book";
16
- static #RESERVE_PLACE = "ReservePlace";
17
- static #CONFIRM_COURSE = "ConfirmCourse";
18
- static #ORDER_TIMEOUT = "OrderTimeout";
19
- static #GET_RESERVATION = "GetReservation";
20
- static #IS_RESERVATION_PAID = "IsReservationPaid";
21
- static #MARK_RESERVATION_PAID = "MarkReservationPaid";
22
-
23
- static async MarkReservationPaid(reservationId, transactionId)
24
- {
25
- var res = await APIController.Get(this.#MODULE, this.#MARK_RESERVATION_PAID, {
26
- 'reservationId': reservationId,
27
- 'transactionId': transactionId,
28
- });
29
-
30
- return APIController.IntToBool(res);
31
- }
32
-
33
- /**
34
- * Get if reservation is paid or not
35
- * @param {*} id reservation order ID
36
- * @returns bool
37
- */
38
- static async IsReservationPaid(id)
39
- {
40
- var res = await APIController.Get(this.#MODULE, this.#IS_RESERVATION_PAID, {
41
- 'order': id,
42
- });
43
-
44
- return APIController.IntToBool(res);
45
- }
46
-
47
- /**
48
- * Get reservation by its ID.
49
- * @param {*} id reservation order ID
50
- * @returns CourseReservation object
51
- */
52
- static async GetReservation(id)
53
- {
54
- var reservationJSON = await APIController.Get(this.#MODULE, this.#GET_RESERVATION, {
55
- 'order': id,
56
- });
57
-
58
- var reservationArray = JSON.parse(reservationJSON);
59
-
60
- var reservation = new CourseReservation();
61
- reservation.CourseId = reservationArray['CourseId'];
62
- reservation.Email = reservationArray['Email'];
63
- reservation.FirstName = reservationArray['FirstName'];
64
- reservation.LastName = reservationArray['LastName'];
65
- reservation.TeacherId = reservationArray['TeacherId'];
66
-
67
- return reservation;
68
- }
69
-
70
- /**
71
- * Checks if your reserved place is still in DB, if not returns true.
72
- *
73
- * This method uses token stored in session, so you have to run ReservePlace
74
- * before to be able to run this method.
75
- *
76
- * Represents creating order timeout.
77
- * @returns bool
78
- */
79
- static async OrderTimeout()
80
- {
81
- var res = await APIController.Get(this.#MODULE, this.#ORDER_TIMEOUT);
82
-
83
- return APIController.IntToBool(res);
84
- }
85
-
86
- /**
87
- * Send notification email about reserving course. Reservation is taken from book,
88
- * which means this method will work only after book.
89
- * @param {*} resend
90
- * @returns Returns true if succeded.
91
- */
92
- static async ConfirmCourse(resend)
93
- {
94
- var res = await APIController.Get(this.#MODULE, this.#CONFIRM_COURSE, {
95
- 'resend': APIController.BoolToInt(resend),
96
- });
97
-
98
- return APIController.IntToBool(res);
99
- }
100
-
101
- /**
102
- * This method is used to reserve place in course without creating reservation.
103
- * Is used to hold course during creating order. Will create unique token which
104
- * is used to identify your reserved place. This token is not returned and is kept
105
- * on backend side.
106
- * @param {*} courseId
107
- * @returns int (BookReturn enum)
108
- */
109
- static async ReservePlace(courseId)
110
- {
111
- var res = await APIController.Post(this.#MODULE, this.#RESERVE_PLACE, {
112
- 'courseId': courseId,
113
- });
114
-
115
- return res;
116
- }
117
-
118
- /**
119
- * Book specific course.
120
- *
121
- * Teacher id is not needed to be specified as will be fetched by course id.
122
- * @param {*} courseReservation CourseReservation object
123
- * @returns int (BookReturn enum)
124
- */
125
- static async Book(courseReservation)
126
- {
127
- var res = await APIController.Post(this.#MODULE, this.#BOOK, {
128
- 'reservation': encodeURIComponent(JSON.stringify(courseReservation)),
129
- });
130
-
131
- return res;
132
- }
133
-
134
- /**
135
- * Get all available courses by specific parameters
136
- * @param {*} school type of scool for the course
137
- * @param {*} subject subject id (0 - math 1 - czech)
138
- * @param {*} length course length (lessons)
139
- * @param {*} capacity course capacity
140
- * @returns Course[]
141
- */
142
- static async GetAvailableCourses(school, subject, length, capacity)
143
- {
144
- var data = await APIController.Get(this.#MODULE, this.#GET_ALL_AVAILABLE_COURSES, {
145
- 'school': school,
146
- 'subject': subject,
147
- 'length': length,
148
- 'capacity': capacity,
149
- });
150
-
151
- // Check if returned data are valid JSON object.
152
- try
153
- {
154
- JSON.parse(data);
155
- }
156
- catch
157
- {
158
- return [];
159
- }
160
-
161
- var dataArray = JSON.parse(data);
162
-
163
- var availableCourses = [];
164
-
165
- for (const [key, value] of Object.entries(dataArray))
166
- {
167
- var course = new Course();
168
-
169
- course.Name = value['Name'];
170
- course.NameRaw = value['NameRaw'];
171
- course.School = value['School'];
172
- course.Price = value['Price'];
173
- course.CreditPrice = value['CreditPrice'];
174
- course.ID = value['ID'];
175
- course.Day = value['Day'];
176
- course.Time = value['Time'];
177
- course.Length = value['Length'];
178
- course.Lessons = value['Lessons'];
179
- course.Capacity = value['Capacity'];
180
- course.Item = value['Item'];
181
- course.Subject = value['Subject'];
182
- course.PriceBeforeSale = value['PriceBeforeSale'];
183
- course.IsSaled = value['IsSaled'];
184
-
185
- availableCourses[course.ID] = course;
186
- }
187
-
188
- return availableCourses;
189
- }
190
-
191
- /**
192
- * Get price of courses
193
- * @param {*} cheap if you want to get the cheapest or the most expensive price tag - bool
194
- * @param {*} paramas - optional - JSON url encoded - additional params to filter the courses - key must be variable name of Course object
195
- * @returns int
196
- */
197
- static async GetPrice(cheap, paramas = [])
198
- {
199
- var price = await APIController.Get(this.#MODULE, this.#GET_PRICE, {
200
- 'cheap': APIController.BoolToInt(cheap),
201
- 'params': encodeURIComponent(JSON.stringify(paramas)),
202
- });
203
-
204
- console.log(price);
205
- return parseInt(price);
206
- }
207
- }
208
-
209
- export default CoursesSystem;