Files
Chamilo/plugin/zoom/lib/API/WebinarSchema.php
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

138 lines
3.2 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\Zoom\API;
use Exception;
use stdClass;
class WebinarSchema
{
use BaseMeetingTrait;
use JsonDeserializableTrait;
public const TYPE_WEBINAR = 5;
public const TYPE_RECURRING_NO_FIXED_TIME = 6;
public const TYPE_RECURRING_FIXED_TIME = 9;
public $uuid;
public $id;
public $host_id;
public $created_at;
public $start_url;
public $join_url;
public $registration_url;
public $password;
/**
* @var WebinarSettings
*/
public $settings;
public $registrants_confirmation_email;
/**
* @var array<int, TrackingField>
*/
public $tracking_fields;
public $recurrence;
public $template_id;
/**
* @var array<int, Ocurrence>
*/
public $ocurrences;
protected function __construct()
{
$this->tracking_fields = [];
$this->settings = new WebinarSettings();
$this->ocurrences = [];
}
public function itemClass($propertyName): string
{
if ('tracking_fields' === $propertyName) {
return TrackingField::class;
}
if ('ocurrences' === $propertyName) {
return Ocurrence::class;
}
throw new Exception("no such array property $propertyName");
}
public static function fromTopicAndType($topic, $type = self::TYPE_WEBINAR): WebinarSchema
{
$instance = new static();
$instance->topic = $topic;
$instance->type = $type;
return $instance;
}
/**
* @throws Exception
*/
public function create($userId = null): WebinarSchema
{
$client = Client::getInstance();
$userId = empty($userId) ? 'me' : $userId;
return self::fromJson(
$client->send('POST', "users/$userId/webinars", [], $this)
);
}
/**
* @throws Exception
*/
public function update(): void
{
Client::getInstance()->send('PATCH', 'webinars/'.$this->id, [], $this);
}
/**
* @throws Exception
*/
public function delete()
{
Client::getInstance()->send('DELETE', "webinars/$this->id");
}
/**
* @throws Exception
*/
public function addRegistrant(RegistrantSchema $registrant, string $occurrenceIds = ''): CreatedRegistration
{
return CreatedRegistration::fromJson(
Client::getInstance()->send(
'POST',
"webinars/$this->id/registrants",
empty($occurrenceIds) ? [] : ['occurrence_ids' => $occurrenceIds],
$registrant
)
);
}
/**
* @throws Exception
*/
public function removeRegistrants(array $registrants, string $occurrenceIds = '')
{
if (empty($registrants)) {
return;
}
$requestBody = new stdClass();
$requestBody->action = 'cancel';
$requestBody->registrants = $registrants;
Client::getInstance()->send(
'PUT',
"webinars/$this->id/registrants/status",
empty($occurrenceIds) ? [] : ['occurrence_ids' => $occurrenceIds],
$requestBody
);
}
}