1
|
|
|
<?php |
2
|
|
|
namespace mikemix\Wiziq\API; |
3
|
|
|
|
4
|
|
|
use mikemix\Wiziq\Common\Api\Exception; |
5
|
|
|
use mikemix\Wiziq\Common\Api\TeacherApiInterface; |
6
|
|
|
use mikemix\Wiziq\Entity\Teacher; |
7
|
|
|
|
8
|
|
|
class TeacherApi implements TeacherApiInterface |
9
|
|
|
{ |
10
|
|
|
/** @var Gateway */ |
11
|
|
|
protected $gateway; |
12
|
|
|
|
13
|
4 |
|
public function __construct(Gateway $requester) |
14
|
|
|
{ |
15
|
4 |
|
$this->gateway = $requester; |
16
|
4 |
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
1 |
|
public function addTeacher(Teacher $teacher) |
22
|
|
|
{ |
23
|
1 |
|
return (int)$this->gateway->sendRequest(new Request\AddTeacher($teacher)) |
24
|
1 |
|
->add_teacher[0]->teacher_id; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
1 |
|
public function editTeacher($teacherId, Teacher $teacher) |
31
|
|
|
{ |
32
|
1 |
|
$this->gateway->sendRequest(new Request\EditTeacher($teacherId, $teacher)); |
33
|
1 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get $teacherId details |
37
|
|
|
* |
38
|
|
|
* @param int $teacherId Wiziq's teacher ID |
39
|
|
|
* @return array Teacher's details |
40
|
|
|
* |
41
|
|
|
* @throws Exception\CallException |
42
|
|
|
*/ |
43
|
1 |
|
public function getTeacherDetails($teacherId) |
44
|
|
|
{ |
45
|
1 |
|
$response = (array)$this->gateway->sendRequest(new Request\GetTeacherDetails($teacherId)) |
46
|
1 |
|
->get_teacher_details[0]->teacher_details_list[0]->teacher_details[0]; |
47
|
|
|
|
48
|
|
|
return [ |
49
|
1 |
|
'teacher_id' => (int)$response['teacher_id'], |
50
|
1 |
|
'name' => (string)$response['name'], |
51
|
1 |
|
'email' => (string)$response['email'], |
52
|
1 |
|
'password' => (string)$response['password'], |
53
|
1 |
|
'phone_number' => (string)$response['phone_number'], |
54
|
1 |
|
'mobile_number' => (string)$response['mobile_number'], |
55
|
1 |
|
'about_the_teacher' => (string)$response['about_the_teacher'], |
56
|
1 |
|
'image' => (string)$response['image'], |
57
|
1 |
|
'time_zone' => (string)$response['time_zone'], |
58
|
1 |
|
'can_schedule_class' => (bool)(string)$response['can_schedule_class'], |
59
|
1 |
|
'is_active' => (bool)(string)$response['is_active'], |
60
|
1 |
|
]; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|