@itutoring/itutoring_application_js_api 1.5.22 → 1.6.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/index.d.ts +0 -2
- package/index.js +0 -2
- package/modules/ReservationSystem.js +8 -0
- package/objects/Course.js +4 -0
- package/objects/CourseReservation.js +4 -0
- package/objects/Reservation.js +4 -0
- package/package.json +1 -1
- package/modules/CoursesSystem.js +0 -209
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,
|
|
@@ -37,6 +37,14 @@ class ReservationSystem
|
|
|
37
37
|
static #GET_CART_ITEMS_COUNT = "GetCartItemsCount";
|
|
38
38
|
static #REMOVE_ITEM_FROM_CART = "RemoveItemFromCart";
|
|
39
39
|
static #GET_AVAILABLE_STATES = "GetAvailableStates";
|
|
40
|
+
static #ORDER_IS_PLACED = "OrderIsPlaced";
|
|
41
|
+
|
|
42
|
+
static async orderIsPlaced()
|
|
43
|
+
{
|
|
44
|
+
var res = await APIController.Get(this.#MODULE, this.#ORDER_IS_PLACED);
|
|
45
|
+
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
40
48
|
|
|
41
49
|
static async getAvailableStates()
|
|
42
50
|
{
|
package/objects/Course.js
CHANGED
package/objects/Reservation.js
CHANGED
package/package.json
CHANGED
package/modules/CoursesSystem.js
DELETED
|
@@ -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;
|