-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathBroadcastList.php
79 lines (69 loc) · 1.92 KB
/
BroadcastList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace OpenTok;
use OpenTok\Util\Client;
use OpenTok\Util\Validators;
/**
* A class for accessing an array of Archive objects.
*/
class BroadcastList
{
/**
* @internal
*/
private $data;
/**
* @internal
*/
private $client;
/**
* @internal
*/
private $items;
/**
* @internal
*/
public function __construct($broadcastListData, $options = array())
{
// unpack optional arguments (merging with default values) into named variables
$defaults = array(
'apiKey' => null,
'apiSecret' => null,
'apiUrl' => 'https://api.opentok.com',
'client' => null
);
$options = array_merge($defaults, array_intersect_key($options, $defaults));
list($apiKey, $apiSecret, $apiUrl, $client) = array_values($options);
// validate params
Validators::validateBroadcastListData($broadcastListData);
Validators::validateClient($client);
$this->data = $broadcastListData;
$this->client = isset($client) ? $client : new Client();
if (!$this->client->isConfigured()) {
Validators::validateApiKey($apiKey);
Validators::validateApiSecret($apiSecret);
Validators::validateApiUrl($apiUrl);
$this->client->configure($apiKey, $apiSecret, $apiUrl);
}
}
/**
* Returns the number of total archives for the API key.
*/
public function totalCount()
{
return $this->data['count'];
}
/**
* Returns an array of Archive objects.
*/
public function getItems()
{
if (!$this->items) {
$items = array();
foreach ($this->data['items'] as $broadcastData) {
$items[] = new Broadcast($broadcastData, array( 'client' => $this->client ));
}
$this->items = $items;
}
return $this->items;
}
}