Skip to content

Commit

Permalink
Merge branch 'main' into update-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
BJTheCod3r authored Mar 11, 2024
2 parents 8395c9e + 42b82ee commit 7715663
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/cloudflare-stream.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

return [

/*
Expand Down
39 changes: 38 additions & 1 deletion src/CloudflareStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,28 @@ public function secureVideo(string $id, array $payload): array
*/
public function subscribeToWebhookNotifications(string $notification_url): array
{
return $this->http->post("{$this->baseUrl}/{$this->accountId}/stream/webhook", [
return $this->http->put("{$this->baseUrl}/{$this->accountId}/stream/webhook", [
'notificationUrl' => $notification_url
])->json();
}

/**
* List videos
*
* @return array
*/
public function indexVideos(array $query = []): array
{
$defaultQuery = [
'include_counts' => 'true',
];

$query = array_merge($defaultQuery, $query);
$query = http_build_query($query);

return $this->http->get("{$this->baseUrl}/{$this->accountId}/stream?$query")->json();
}

/**
* Fetch video details
*
Expand All @@ -244,6 +261,26 @@ public function updateMeta(string $id, array $meta = []): array
'meta' => $meta
])->json();
}

/**
* Clip a video
*
* @param string $id
* @return array
* @param array $options
*/
public function clip(string $id, array $options = []): array
{
$payload = [
'clippedFromVideoUID' => $id
];

if (!empty($options = array_merge($this->prepareData($options), $this->prepareData($this->defaultOptions)))) {
$payload = array_merge($payload, $options);
}

return $this->http->post("{$this->baseUrl}/{$this->accountId}/stream/clip", $payload)->json();
}

/**
* Delete video
Expand Down

0 comments on commit 7715663

Please sign in to comment.