Skip to content

Commit ecd5fcc

Browse files
committed
Add includeInternalPublication parameter to Events API methods,
fixes #37
1 parent cf34136 commit ecd5fcc

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
- Repair and enhance Event API `addTrack`under `/api/events/{eventId}/track` [#36]
6262
- Tags are now added, therefore it can be replaced by ingest method.
6363
- overwriteExisting flag has been fixed and works as expected now!
64-
64+
- Introduce `includeInternalPublication` in Events API `getAll`, `get` and `getPublications` methods [#37]

src/OpencastApi/Rest/OcEventsApi.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct($restClient)
2424
* 'withmetadata' => (boolean) {Whether the metadata catalogs should be included in the response. },
2525
* 'withscheduling' => (boolean) {Whether the scheduling information should be included in the response. (version 1.1.0 and higher)},
2626
* 'withpublications' => (boolean) {Whether the publication ids and urls should be included in the response.},
27+
* 'includeInternalPublication' => (boolean) {Whether internal publications should be included.},
2728
* 'onlyWithWriteAccess' => (boolean) {Whether only to get the events to which we have write access.},
2829
* 'sort' => (array) {an assiciative array for sorting e.g. ['title' => 'DESC']},
2930
* 'limit' => (int) {the maximum number of results to return},
@@ -47,7 +48,7 @@ public function getAll($params = [])
4748

4849
$acceptableParams = [
4950
'sign', 'withacl', 'withmetadata', 'withpublications',
50-
'onlyWithWriteAccess', 'sort', 'limit', 'offset', 'filter'
51+
'onlyWithWriteAccess', 'sort', 'limit', 'offset', 'filter', 'includeInternalPublication'
5152
];
5253

5354
if ($this->restClient->hasVersion('1.1.0')) {
@@ -106,6 +107,7 @@ public function getBySeries($seriesId, $params = [])
106107
* 'withmetadata' => (boolean) {Whether the metadata catalogs should be included in the response. },
107108
* 'withscheduling' => (boolean) {Whether the scheduling information should be included in the response. (version 1.1.0 and higher)},
108109
* 'withpublications' => (boolean) {Whether the publication ids and urls should be included in the response.}
110+
* 'includeInternalPublication' => (boolean) {Whether internal publications should be included.}
109111
* ]
110112
*
111113
* @return array the response result ['code' => 200, 'body' => 'The event (Object)']
@@ -116,7 +118,7 @@ public function get($eventId, $params = [])
116118
$query = [];
117119

118120
$acceptableParams = [
119-
'sign', 'withacl', 'withmetadata', 'withpublications'
121+
'sign', 'withacl', 'withmetadata', 'withpublications', 'includeInternalPublication'
120122
];
121123

122124
if ($this->restClient->hasVersion('1.1.0')) {
@@ -438,13 +440,20 @@ public function deleteMetadata($eventId, $type)
438440
*
439441
* @param string $eventId the event identifier
440442
* @param boolean $sign (optional) Whether publication urls (version 1.7.0 or higher) and distribution urls should be pre-signed.
443+
* @param boolean $includeInternalPublication (optional) Whether internal publications should be included.
441444
*
442445
* @return array the response result ['code' => 200, 'body' => '{The list of publications}']
443446
*/
444-
public function getPublications($eventId, $sign = false)
447+
public function getPublications($eventId, $sign = false, $includeInternalPublication = false)
445448
{
446449
$uri = self::URI . "/{$eventId}/publications";
447-
$query['sign'] = $sign;
450+
if ($sign) {
451+
$query['sign'] = 'true';
452+
}
453+
if ($includeInternalPublication) {
454+
$query['includeInternalPublication'] = 'true';
455+
}
456+
448457
$options = $this->restClient->getQueryParams($query);
449458
return $this->restClient->performGet($uri, $options);
450459
}

tests/DataProvider/EventsDataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public static function getAllCases(): array
1313
[['withmetadata' => true]],
1414
[['withpublications' => true]],
1515
[['withscheduling' => true]],
16+
[['includeInternalPublication' => true]],
1617
[['sort' => ['title' => 'DESC']]],
1718
[['limit' => 2]],
1819
[['offset' => 1, 'limit' => 2]],

tests/Unit/OcEventsApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function empty_random_event_id(): string
5454
*/
5555
public function get_single_event(string $identifier): string
5656
{
57-
$responseAll = $this->ocEventsApi->getAll(['withacl' => true]);
57+
$responseAll = $this->ocEventsApi->getAll(['withacl' => true, 'includeInternalPublication' => true]);
5858
$this->assertSame(200, $responseAll['code'], 'Failure to get event list');
5959
$events = $responseAll['body'];
6060
if (!empty($events)) {
@@ -289,7 +289,7 @@ public function get_update_delete_metadata(string $identifier): string
289289
*/
290290
public function get_publications(string $identifier): string
291291
{
292-
$response1 = $this->ocEventsApi->getPublications($identifier, true);
292+
$response1 = $this->ocEventsApi->getPublications($identifier, true, true);
293293
$this->assertSame(200, $response1['code'], 'Failure to get publications of an event');
294294

295295
$publications = $response1['body'];

0 commit comments

Comments
 (0)