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