Passed
Push — master ( c22b6a...5f79f5 )
by Julito
11:21
created

MeetingInfoGet   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 134
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
c 0
b 0
f 0
dl 0
loc 134
rs 10
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 1
A delete() 0 3 1
A removeRegistrants() 0 10 3
A addRegistrant() 0 8 2
A fromId() 0 3 1
A getRegistrants() 0 3 1
A endNow() 0 3 1
A getInstances() 0 3 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\Zoom\API;
6
7
use Exception;
8
9
/**
10
 * Class MeetingInfoGet
11
 * Full Meeting as returned by the server, with unique identifiers and current status.
12
 */
13
class MeetingInfoGet extends MeetingInfo
14
{
15
    /** @var string unique meeting instance ID */
16
    public $uuid;
17
18
    /** @var string meeting number */
19
    public $id;
20
21
    /** @var string host Zoom user id */
22
    public $host_id;
23
24
    /** @var string meeting status, either "waiting", "started" or "finished" */
25
    public $status;
26
27
    /** @var string undocumented */
28
    public $pstn_password;
29
30
    /** @var string Encrypted password for third party endpoints (H323/SIP). */
31
    public $encrypted_password;
32
33
    /**
34
     * Retrieves a meeting from its numeric identifier.
35
     *
36
     * @param int $id
37
     *
38
     * @throws Exception
39
     *
40
     * @return static the meeting
41
     */
42
    public static function fromId($id)
43
    {
44
        return static::fromJson(Client::getInstance()->send('GET', "meetings/$id"));
45
    }
46
47
    /**
48
     * Updates the meeting on server.
49
     *
50
     * @throws Exception
51
     */
52
    public function update()
53
    {
54
        Client::getInstance()->send('PATCH', 'meetings/'.$this->id, [], $this);
55
    }
56
57
    /**
58
     * Ends the meeting on server.
59
     *
60
     * @throws Exception
61
     */
62
    public function endNow()
63
    {
64
        Client::getInstance()->send('PUT', "meetings/$this->id/status", [], (object) ['action' => 'end']);
65
    }
66
67
    /**
68
     * Deletes the meeting on server.
69
     *
70
     * @throws Exception
71
     */
72
    public function delete()
73
    {
74
        Client::getInstance()->send('DELETE', "meetings/$this->id");
75
    }
76
77
    /**
78
     * Adds a registrant to the meeting.
79
     *
80
     * @param MeetingRegistrant $registrant    with at least 'email' and 'first_name'.
81
     *                                         'last_name' will also be recorded by Zoom.
82
     *                                         Other properties remain ignored, or not returned by Zoom
83
     *                                         (at least while using profile "Pro")
84
     * @param string            $occurrenceIds separated by comma
85
     *
86
     * @throws Exception
87
     *
88
     * @return CreatedRegistration with unique join_url and registrant_id properties
89
     */
90
    public function addRegistrant($registrant, $occurrenceIds = '')
91
    {
92
        return CreatedRegistration::fromJson(
93
            Client::getInstance()->send(
94
                'POST',
95
                "meetings/$this->id/registrants",
96
                empty($occurrenceIds) ? [] : ['occurrence_ids' => $occurrenceIds],
97
                $registrant
98
            )
99
        );
100
    }
101
102
    /**
103
     * Removes registrants from the meeting.
104
     *
105
     * @param MeetingRegistrant[] $registrants   registrants to remove (id and email)
106
     * @param string              $occurrenceIds separated by comma
107
     *
108
     * @throws Exception
109
     */
110
    public function removeRegistrants($registrants, $occurrenceIds = '')
111
    {
112
        if (!empty($registrants)) {
113
            Client::getInstance()->send(
114
                'PUT',
115
                "meetings/$this->id/registrants/status",
116
                empty($occurrenceIds) ? [] : ['occurrence_ids' => $occurrenceIds],
117
                (object) [
118
                    'action' => 'cancel',
119
                    'registrants' => $registrants,
120
                ]
121
            );
122
        }
123
    }
124
125
    /**
126
     * Retrieves meeting registrants.
127
     *
128
     * @throws Exception
129
     *
130
     * @return MeetingRegistrantListItem[] the meeting registrants
131
     */
132
    public function getRegistrants()
133
    {
134
        return MeetingRegistrantList::loadMeetingRegistrants($this->id);
135
    }
136
137
    /**
138
     * Retrieves the meeting's instances.
139
     *
140
     * @throws Exception
141
     *
142
     * @return MeetingInstance[]
143
     */
144
    public function getInstances()
145
    {
146
        return MeetingInstances::fromMeetingId($this->id)->meetings;
147
    }
148
}
149