|
1
|
|
|
<?php |
|
2
|
|
|
namespace mikemix\Wiziq\API; |
|
3
|
|
|
|
|
4
|
|
|
use mikemix\Wiziq\API\Request; |
|
5
|
|
|
use mikemix\Wiziq\Common\Api\ClassroomApiInterface; |
|
6
|
|
|
use mikemix\Wiziq\Entity\Attendees; |
|
7
|
|
|
use mikemix\Wiziq\Entity\Classroom; |
|
8
|
|
|
use mikemix\Wiziq\Entity\PermaClassroom; |
|
9
|
|
|
|
|
10
|
|
|
class ClassroomApi implements ClassroomApiInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var Gateway */ |
|
13
|
|
|
protected $gateway; |
|
14
|
|
|
|
|
15
|
5 |
|
public function __construct(Gateway $requester) |
|
16
|
|
|
{ |
|
17
|
5 |
|
$this->gateway = $requester; |
|
18
|
5 |
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritdoc} |
|
22
|
|
|
*/ |
|
23
|
1 |
|
public function create(Classroom $classroom) |
|
24
|
|
|
{ |
|
25
|
1 |
|
$response = $this->gateway->sendRequest(new Request\Create($classroom)) |
|
26
|
1 |
|
->create[0]->class_details[0]; |
|
27
|
|
|
|
|
28
|
|
|
return [ |
|
29
|
1 |
|
'class_id' => (int)$response->class_id, |
|
30
|
1 |
|
'recording_url' => (string)$response->recording_url, |
|
31
|
1 |
|
'presenter_email' => (string)$response->presenter_list[0]->presenter[0]->presenter_email, |
|
32
|
1 |
|
'presenter_url' => (string)$response->presenter_list[0]->presenter[0]->presenter_url, |
|
33
|
1 |
|
]; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function cancel($classroomId) |
|
40
|
|
|
{ |
|
41
|
1 |
|
$this->gateway->sendRequest(new Request\Cancel($classroomId)); |
|
42
|
1 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* {@inheritdoc} |
|
46
|
|
|
*/ |
|
47
|
1 |
|
public function createPermaClas(PermaClassroom $classroom) |
|
48
|
|
|
{ |
|
49
|
1 |
|
$response = $this->gateway->sendRequest(new Request\CreatePermaClass($classroom)); |
|
50
|
1 |
|
$details = $response->create_perma_class[0]->perma_class_details[0]; |
|
51
|
|
|
|
|
52
|
|
|
return [ |
|
53
|
1 |
|
'class_id' => (int)$details->class_master_id, |
|
54
|
1 |
|
'attendee_url' => (string)$details->common_perma_attendee_url, |
|
55
|
1 |
|
'presenter_email' => (string)$details->presenter[0]->presenter_email, |
|
56
|
1 |
|
'presenter_url' => (string)$details->presenter[0]->presenter_url, |
|
57
|
1 |
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function addAttendeesToClass($classroomId, Attendees $attendees) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$response = $this->gateway->sendRequest(new Request\AddAttendees($classroomId, $attendees)); |
|
66
|
1 |
|
$result = []; |
|
67
|
|
|
|
|
68
|
1 |
|
foreach ($response->add_attendees[0]->attendee_list[0] as $attendee) { |
|
69
|
1 |
|
$result[] = ['id' => (int)$attendee->attendee_id, 'url' => (string)$attendee->attendee_url]; |
|
70
|
1 |
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
return $result; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param \SimpleXMLElement $response |
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function getPresentersFromResponse(\SimpleXMLElement $response) |
|
80
|
|
|
{ |
|
81
|
|
|
$presenters = []; |
|
82
|
|
|
foreach ($response->presenter_list[0] as $presenter) { |
|
83
|
|
|
$presenters[] = [ |
|
84
|
|
|
'email' => (string)$presenter->presenter_email, |
|
85
|
|
|
'url' => (string)$presenter->presenter_url, |
|
86
|
|
|
]; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $presenters; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|