Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new webhooks #99

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/Api/WebhooksApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ Method | Description | HTTP request

Webhooks can push notifications to your server, rather than polling api.video for changes. We currently offer four events:

* ```video.encoding.quality.completed``` Occurs when a new video is uploaded into your account, it will be encoded into several different HLS and mp4 qualities. When each version is encoded, your webhook will get a notification. It will look like ```{ "type": "video.encoding.quality.completed", "emittedAt": "2021-01-29T16:46:25.217+01:00", "videoId": "viXXXXXXXX", "encoding": "hls", "quality": "720p"} ```. This request says that the 720p HLS encoding was completed.
* `video.encoding.quality.completed` Occurs when a new video is uploaded into your account, it will be encoded into several different HLS and mp4 qualities. When each version is encoded, your webhook will get a notification. It will look like ```{ "type": "video.encoding.quality.completed", "emittedAt": "2021-01-29T16:46:25.217+01:00", "videoId": "viXXXXXXXX", "encoding": "hls", "quality": "720p"} ```. This request says that the 720p HLS encoding was completed.

* ```live-stream.broadcast.started``` When a live stream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires.
* `live-stream.broadcast.started` When a live stream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires.

* ```live-stream.broadcast.ended``` This event fires when a live stream has finished broadcasting.
* `live-stream.broadcast.ended` This event fires when a live stream has finished broadcasting.

* ```video.source.recorded``` This event occurs when a live stream is recorded and submitted for encoding.
* `video.source.recorded` This event occurs when a live stream is recorded and submitted for encoding.

* `video.caption.generated` This event occurs when an automatic caption has been generated.

* `video.summary.generated` This event occurs when an automatic summary has been generated.

### Arguments

Expand Down
2 changes: 1 addition & 1 deletion docs/Model/WebhooksCreationPayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**events** | **string[]** | A list of the webhooks that you are subscribing to. There are Currently four webhook options: * ```video.encoding.quality.completed``` Occurs when a new video is uploaded into your account, it will be encoded into several different HLS and mp4 qualities. When each version is encoded, your webhook will get a notification. It will look like ```{ \\\"type\\\": \\\"video.encoding.quality.completed\\\", \\\"emittedAt\\\": \\\"2021-01-29T16:46:25.217+01:00\\\", \\\"videoId\\\": \\\"viXXXXXXXX\\\", \\\"encoding\\\": \\\"hls\\\", \\\"quality\\\": \\\"720p\\\"} ```. This request says that the 720p HLS encoding was completed. * ```live-stream.broadcast.started``` When a live stream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires. * ```live-stream.broadcast.ended``` This event fires when a live stream has finished broadcasting. * ```video.source.recorded``` Occurs when a live stream is recorded and submitted for encoding. |
**events** | **string[]** | An array of webhook events that you want to subscribe to. |
**url** | **string** | The the url to which HTTP notifications are sent. It could be any http or https URL. |

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
32 changes: 32 additions & 0 deletions src/Model/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,29 @@ public static function getDefinition(): ModelDefinition
);
}

const EVENTS_LIVE_STREAM_BROADCAST_STARTED = 'live-stream.broadcast.started';
const EVENTS_LIVE_STREAM_BROADCAST_ENDED = 'live-stream.broadcast.ended';
const EVENTS_VIDEO_SOURCE_RECORDED = 'video.source.recorded';
const EVENTS_VIDEO_ENCODING_QUALITY_COMPLETED = 'video.encoding.quality.completed';
const EVENTS_VIDEO_CAPTION_GENERATED = 'video.caption.generated';
const EVENTS_VIDEO_SUMMARY_GENERATED = 'video.summary.generated';

/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getEventsAllowableValues()
{
return [
self::EVENTS_LIVE_STREAM_BROADCAST_STARTED,
self::EVENTS_LIVE_STREAM_BROADCAST_ENDED,
self::EVENTS_VIDEO_SOURCE_RECORDED,
self::EVENTS_VIDEO_ENCODING_QUALITY_COMPLETED,
self::EVENTS_VIDEO_CAPTION_GENERATED,
self::EVENTS_VIDEO_SUMMARY_GENERATED,
];
}

/**
* Associative array for storing property values
Expand Down Expand Up @@ -190,6 +213,15 @@ public function getEvents()
*/
public function setEvents($events)
{
$allowedValues = $this->getEventsAllowableValues();
if (!is_null($events) && array_diff($events, $allowedValues)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'events', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['events'] = $events;

return $this;
Expand Down
34 changes: 33 additions & 1 deletion src/Model/WebhooksCreationPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ public static function getDefinition(): ModelDefinition
);
}

const EVENTS_LIVE_STREAM_BROADCAST_STARTED = 'live-stream.broadcast.started';
const EVENTS_LIVE_STREAM_BROADCAST_ENDED = 'live-stream.broadcast.ended';
const EVENTS_VIDEO_SOURCE_RECORDED = 'video.source.recorded';
const EVENTS_VIDEO_ENCODING_QUALITY_COMPLETED = 'video.encoding.quality.completed';
const EVENTS_VIDEO_CAPTION_GENERATED = 'video.caption.generated';
const EVENTS_VIDEO_SUMMARY_GENERATED = 'video.summary.generated';

/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getEventsAllowableValues()
{
return [
self::EVENTS_LIVE_STREAM_BROADCAST_STARTED,
self::EVENTS_LIVE_STREAM_BROADCAST_ENDED,
self::EVENTS_VIDEO_SOURCE_RECORDED,
self::EVENTS_VIDEO_ENCODING_QUALITY_COMPLETED,
self::EVENTS_VIDEO_CAPTION_GENERATED,
self::EVENTS_VIDEO_SUMMARY_GENERATED,
];
}

/**
* Associative array for storing property values
Expand Down Expand Up @@ -121,12 +144,21 @@ public function getEvents()
/**
* Sets events
*
* @param string[] $events A list of the webhooks that you are subscribing to. There are Currently four webhook options: * ```video.encoding.quality.completed``` Occurs when a new video is uploaded into your account, it will be encoded into several different HLS and mp4 qualities. When each version is encoded, your webhook will get a notification. It will look like ```{ \\\"type\\\": \\\"video.encoding.quality.completed\\\", \\\"emittedAt\\\": \\\"2021-01-29T16:46:25.217+01:00\\\", \\\"videoId\\\": \\\"viXXXXXXXX\\\", \\\"encoding\\\": \\\"hls\\\", \\\"quality\\\": \\\"720p\\\"} ```. This request says that the 720p HLS encoding was completed. * ```live-stream.broadcast.started``` When a live stream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires. * ```live-stream.broadcast.ended``` This event fires when a live stream has finished broadcasting. * ```video.source.recorded``` Occurs when a live stream is recorded and submitted for encoding.
* @param string[] $events An array of webhook events that you want to subscribe to.
*
* @return self
*/
public function setEvents($events)
{
$allowedValues = $this->getEventsAllowableValues();
if (array_diff($events, $allowedValues)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value for 'events', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['events'] = $events;

return $this;
Expand Down
Loading