Skip to content

Commit 0c90dcd

Browse files
committed
Adds subscriptions.
1 parent d8a0c1e commit 0c90dcd

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

lib/Brightcove/API/CMS.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Brightcove\API;
33

4+
use Brightcove\API\Request\SubscriptionRequest;
5+
use Brightcove\Object\Video\Subscription;
46
use Brightcove\Object\Video\Video;
57
use Brightcove\Object\Video\Source;
68
use Brightcove\Object\Video\Images;
@@ -194,4 +196,19 @@ public function getVideoCountInPlaylist($playlist_id) {
194196
public function getVideosInPlaylist($playlist_id) {
195197
return $this->cmsRequest('GET', "/playlists/{$playlist_id}/videos", Video::class, TRUE);
196198
}
199+
200+
/**
201+
* @return Subscription[]|null
202+
*/
203+
public function getSubscriptions() {
204+
return $this->cmsRequest('GET', '/subscriptions', Subscription::class, TRUE);
205+
}
206+
207+
/**
208+
* @param SubscriptionRequest $request
209+
* @return Subscription|null
210+
*/
211+
public function createSubscription(SubscriptionRequest $request) {
212+
return $this->cmsRequest('POST', '/subscriptions', Subscription::class, FALSE, $request);
213+
}
197214
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Brightcove\API\Request;
4+
5+
use Brightcove\Object\ObjectBase;
6+
7+
class SubscriptionRequest extends ObjectBase {
8+
9+
/**
10+
* @var string
11+
*/
12+
protected $endpoint;
13+
14+
/**
15+
* @var array
16+
*/
17+
protected $events;
18+
19+
public function applyJSON(array $json) {
20+
parent::applyJSON($json);
21+
$this->applyProperty($json, 'endpoint');
22+
$this->applyProperty($json, 'events');
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function getEndpoint() {
29+
return $this->endpoint;
30+
}
31+
32+
/**
33+
* @param string $endpoint
34+
* @return SubscriptionRequest
35+
*/
36+
public function setEndpoint($endpoint) {
37+
$this->endpoint = $endpoint;
38+
$this->fieldChanged('endpoint');
39+
return $this;
40+
}
41+
42+
/**
43+
* @return array
44+
*/
45+
public function getEvents() {
46+
return $this->events;
47+
}
48+
49+
/**
50+
* @param array $events
51+
* @return SubscriptionRequest
52+
*/
53+
public function setEvents(array $events) {
54+
$this->events = $events;
55+
$this->fieldChanged('events');
56+
return $this;
57+
}
58+
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Brightcove\Object\Video;
4+
5+
use Brightcove\API\Request\SubscriptionRequest;
6+
7+
class Subscription extends SubscriptionRequest {
8+
9+
/**
10+
* @var string
11+
*/
12+
protected $id;
13+
14+
/**
15+
* @var string
16+
*/
17+
protected $service_account;
18+
19+
public function applyJSON(array $json) {
20+
parent::applyJSON($json);
21+
$this->applyProperty($json, 'id');
22+
$this->applyProperty($json, 'service_account');
23+
}
24+
25+
26+
/**
27+
* @return string
28+
*/
29+
public function getId() {
30+
return $this->id;
31+
}
32+
33+
/**
34+
* @param string $id
35+
* @return Subscription
36+
*/
37+
public function setId($id) {
38+
$this->id = $id;
39+
$this->fieldChanged('id');
40+
return $this;
41+
}
42+
43+
/**
44+
* @return string
45+
*/
46+
public function getServiceAccount() {
47+
return $this->service_account;
48+
}
49+
50+
/**
51+
* @param string $service_account
52+
* @return Subscription
53+
*/
54+
public function setServiceAccount($service_account) {
55+
$this->service_account = $service_account;
56+
$this->fieldChanged('service_account');
57+
return $this;
58+
}
59+
}

0 commit comments

Comments
 (0)