@itutoring/itutoring_application_js_api 1.1.48 → 1.2.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
@@ -32,6 +32,8 @@ import Subject from "./objects/Subject";
32
32
  import Teacher from "./objects/Teacher";
33
33
  import TeacherProfile from "./objects/TeacherProfile";
34
34
  import iEvent from "./objects/Event";
35
+ import AuthUser from "./objects/AuthUser";
36
+ import Authentication from "./modules/Authentication";
35
37
 
36
38
  import
37
39
  {
@@ -40,7 +42,8 @@ import
40
42
  PaymentType,
41
43
  DeviceOS,
42
44
  PasswordChange,
43
- R_KEYs
45
+ R_KEYs,
46
+ AuthType,
44
47
  } from "./objects/Enums";
45
48
 
46
49
  export
@@ -66,6 +69,7 @@ export
66
69
  EventManager,
67
70
  iTutoringApplicationVersion,
68
71
  LessonManager,
72
+ Authentication,
69
73
 
70
74
  Course,
71
75
  CourseReservation,
@@ -75,11 +79,13 @@ export
75
79
  Teacher,
76
80
  TeacherProfile,
77
81
  iEvent,
82
+ AuthUser,
78
83
 
79
84
  BookReturn,
80
85
  AuthResult,
81
86
  PaymentType,
82
87
  DeviceOS,
83
88
  PasswordChange,
84
- R_KEYs
89
+ R_KEYs,
90
+ AuthType
85
91
  }
package/index.js CHANGED
@@ -30,6 +30,8 @@ import Subject from "./objects/Subject";
30
30
  import Teacher from "./objects/Teacher";
31
31
  import TeacherProfile from "./objects/TeacherProfile";
32
32
  import iEvent from "./objects/Event";
33
+ import AuthUser from "./objects/AuthUser";
34
+ import Authentication from "./modules/Authentication";
33
35
 
34
36
  import
35
37
  {
@@ -38,7 +40,8 @@ import
38
40
  PaymentType,
39
41
  DeviceOS,
40
42
  PasswordChange,
41
- R_KEYs
43
+ R_KEYs,
44
+ AuthType
42
45
  } from "./objects/Enums";
43
46
 
44
47
  export
@@ -64,6 +67,7 @@ export
64
67
  EventManager,
65
68
  iTutoringApplicationVersion,
66
69
  LessonManager,
70
+ Authentication,
67
71
 
68
72
  Course,
69
73
  CourseReservation,
@@ -73,11 +77,13 @@ export
73
77
  Teacher,
74
78
  TeacherProfile,
75
79
  iEvent,
80
+ AuthUser,
76
81
 
77
82
  BookReturn,
78
83
  AuthResult,
79
84
  PaymentType,
80
85
  DeviceOS,
81
86
  PasswordChange,
82
- R_KEYs
87
+ R_KEYs,
88
+ AuthType
83
89
  }
@@ -0,0 +1,60 @@
1
+ import APIController from "../apiController";
2
+ import AuthUser from "../objects/AuthUser";
3
+ import TeacherProfile from "../objects/TeacherProfile";
4
+
5
+ class Authentication
6
+ {
7
+ static #MODULE = "Authentication";
8
+
9
+ static #LOG_IN = "LogIn";
10
+ static #IS_AUTHENTICATED = "IsAuthenticated";
11
+ static #GET_USER_INFO = "GetUserInfo";
12
+
13
+ static async LogIn(email, pass, type)
14
+ {
15
+ var res = await APIController.Post(this.#MODULE, this.#LOG_IN, {
16
+ "email": email,
17
+ "pass": pass,
18
+ "type": type,
19
+ });
20
+
21
+ return res;
22
+ }
23
+
24
+ static async IsAuthenticated()
25
+ {
26
+ var res = await APIController.Get(this.#MODULE, this.#IS_AUTHENTICATED);
27
+ return APIController.IntToBool(res);
28
+ }
29
+
30
+ static async GetUserInfo()
31
+ {
32
+ var userString = await APIController.Get(this.#MODULE, this.#GET_USER_INFO);
33
+ var arr = JSON.parse(userString);
34
+
35
+ var user = new AuthUser();
36
+ user.AuthenticationMethod = user['AuthenticationMethod'];
37
+
38
+ user.ID = arr['ID'];
39
+ user.Name = arr['Name'];
40
+ user.Email = arr['Email'];
41
+ user.Phone = arr['Phone'];
42
+ user.EduMeetLink = arr['EduMeetLink'];
43
+ user.BitmojiURL = arr['BitmojiURL'];
44
+ user.ModuleAccess = arr['ModuleAccess'];
45
+ user.TeachedLessons = arr['TeachedLessons'];
46
+ if (arr['TeacherProfile'] != undefined | null)
47
+ {
48
+ var profile = new TeacherProfile();
49
+ profile.Bio = arr['TeacherProfile']['Bio'];
50
+ profile.Name = arr['TeacherProfile']['Name'];
51
+ profile.PhotoPath = arr['TeacherProfile']['PhotoPath'];
52
+
53
+ user.TeacherProfile = profile;
54
+ }
55
+
56
+ return user;
57
+ }
58
+ }
59
+
60
+ export default Authentication;
@@ -51,9 +51,11 @@ class LessonManager
51
51
  /**
52
52
  * Will create a new event.
53
53
  */
54
- static async CreateEvent()
54
+ static async CreateEvent(defaultTimeUnix = null)
55
55
  {
56
- await APIController.Post(this.#MODULE, this.#CREATE_EVENT);
56
+ await APIController.Post(this.#MODULE, this.#CREATE_EVENT, {
57
+ 'def_time': defaultTimeUnix,
58
+ });
57
59
  }
58
60
  }
59
61
 
@@ -0,0 +1,16 @@
1
+ class AuthUser
2
+ {
3
+ AuthenticationMethod;
4
+
5
+ ID;
6
+ Name;
7
+ Email;
8
+ Phone;
9
+ EduMeetLink;
10
+ BitmojiURL;
11
+ ModuleAccess;
12
+ TeacherProfile;
13
+ TeachedLessons;
14
+ }
15
+
16
+ export default AuthUser;
package/objects/Enums.js CHANGED
@@ -37,6 +37,11 @@ const R_KEYs = {
37
37
  r_key_live: 'r_key_live'
38
38
  }
39
39
 
40
+ const AuthType = {
41
+ Teacher: 0,
42
+ Customer: 1,
43
+ }
44
+
40
45
  export
41
46
  {
42
47
  BookReturn,
@@ -44,5 +49,6 @@ export
44
49
  PaymentType,
45
50
  DeviceOS,
46
51
  PasswordChange,
47
- R_KEYs
52
+ R_KEYs,
53
+ AuthType
48
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itutoring/itutoring_application_js_api",
3
- "version": "1.1.48",
3
+ "version": "1.2.1",
4
4
  "description": "Javascript API for iTutoring Application",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",