Skip to content

Commit

Permalink
add workflow config params into ingest, fixes #24 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Jun 12, 2024
1 parent f656214 commit f1227e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/OpencastApi/Rest/OcIngest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,11 @@ public function addTrackUrl($mediaPackage, $flavor, $url, $tags = '')
* @param string $mediaPackage The media package
* @param string $workflowDefinitionId (optional) Workflow definition id
* @param string $workflowInstanceId (optional) The workflow instance ID to associate this ingest with scheduled events.
* @param array $workflowConfiguration Workflow configuration
*
* @return array the response result ['code' => 200, 'body' => '{XML (text) media package}']
*/
public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInstanceId = '')
public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInstanceId = '', $workflowConfiguration = [])
{
$uri = self::URI . "/ingest";
if (!empty($workflowDefinitionId) && empty($workflowInstanceId)) {
Expand All @@ -450,6 +451,13 @@ public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInsta
$formData['workflowInstanceId'] = $workflowInstanceId;
}

if (!empty($workflowConfiguration)) {
// Adding workflow configuration params into the form data one by one.
foreach ($workflowConfiguration as $config => $value) {
$formData[$config] = $value;
}
}

$options = $this->restClient->getFormParams($formData);

return $this->restClient->performPost($uri, $options);
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/OcIngestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ public function add_attachment_all(array $ingestData): array
public function ingest(array $ingestData): void
{
$workflowDefinitionId = 'schedule-and-upload';
$responseIngest = $this->ocIngest->ingest($ingestData['mediaPackage'], $workflowDefinitionId);
// Add workflow configuration params.
$workflowConfiguration = [
'straightToPublishing' => false
];
$responseIngest = $this->ocIngest->ingest($ingestData['mediaPackage'], $workflowDefinitionId, '', $workflowConfiguration);
$this->assertSame(200, $responseIngest['code'], 'Failure to ingest');
$mediaPackage = $responseIngest['body'];
$this->assertNotEmpty($mediaPackage);
Expand Down

0 comments on commit f1227e5

Please sign in to comment.