1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApiVideo\Client; |
4
|
|
|
|
5
|
|
|
use ApiVideo\Client\Api\Account; |
6
|
|
|
use ApiVideo\Client\Api\AnalyticsLive; |
7
|
|
|
use ApiVideo\Client\Api\AnalyticsVideo; |
8
|
|
|
use ApiVideo\Client\Api\Captions; |
9
|
|
|
use ApiVideo\Client\Api\Lives; |
10
|
|
|
use ApiVideo\Client\Api\Players; |
11
|
|
|
use ApiVideo\Client\Api\Videos; |
12
|
|
|
use ApiVideo\Client\Api\Tokens; |
13
|
|
|
use ApiVideo\Client\Buzz\OAuthBrowser; |
14
|
|
|
use Buzz\Client\Curl; |
15
|
|
|
use Buzz\Client\FileGetContents; |
16
|
|
|
|
17
|
|
|
final class Client |
18
|
|
|
{ |
19
|
|
|
/** @var Videos */ |
20
|
|
|
public $videos; |
21
|
|
|
|
22
|
|
|
/** @var Lives */ |
23
|
|
|
public $lives; |
24
|
|
|
|
25
|
|
|
/** @var Players */ |
26
|
|
|
public $players; |
27
|
|
|
|
28
|
|
|
/** @var Captions */ |
29
|
|
|
public $captions; |
30
|
|
|
|
31
|
|
|
/** @var Tokens */ |
32
|
|
|
public $tokens; |
33
|
|
|
|
34
|
|
|
/** @var AnalyticsVideo */ |
35
|
|
|
public $analyticsVideo; |
36
|
|
|
|
37
|
|
|
/** @var AnalyticsLive */ |
38
|
|
|
public $analyticsLive; |
39
|
|
|
|
40
|
|
|
/** @var Account */ |
41
|
|
|
public $account; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Create client for production environment. |
45
|
|
|
* @param string $apiKey |
46
|
|
|
* @return Client |
47
|
|
|
*/ |
48
|
|
|
public static function create($apiKey) |
49
|
|
|
{ |
50
|
|
|
return new Client($apiKey, 'https://ws.api.video'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Create client for sandbox environment. |
55
|
|
|
* @param string $apiKey |
56
|
|
|
* @return Client |
57
|
|
|
*/ |
58
|
|
|
public static function createSandbox($apiKey) |
59
|
|
|
{ |
60
|
|
|
return new Client($apiKey, 'https://sandbox.api.video'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @deprecated Use Client::create() or Client::createSandbox() instead |
65
|
|
|
* @param string $apiKey |
66
|
|
|
* @param string $baseUri |
67
|
|
|
*/ |
68
|
|
|
public function __construct($apiKey, $baseUri = 'https://ws.api.video') |
69
|
|
|
{ |
70
|
|
|
$client = extension_loaded('curl') ? new Curl : new FileGetContents; |
71
|
|
|
$browser = new OAuthBrowser($client); |
72
|
|
|
$browser->setBaseUri($baseUri); |
73
|
|
|
$browser->authenticate($apiKey); |
74
|
|
|
|
75
|
|
|
$this->videos = new Videos($browser); |
76
|
|
|
$this->lives = new Lives($browser); |
77
|
|
|
$this->players = new Players($browser); |
78
|
|
|
$this->captions = new Captions($browser); |
79
|
|
|
$this->analyticsVideo = new AnalyticsVideo($browser); |
80
|
|
|
$this->analyticsLive = new AnalyticsLive($browser); |
81
|
|
|
$this->tokens = new Tokens($browser); |
82
|
|
|
$this->account = new Account($browser); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|