Skip to content

Commit

Permalink
Merge pull request #103 from apivideo/add-new-webhooks
Browse files Browse the repository at this point in the history
Add new webhooks
  • Loading branch information
bot-api-video authored Nov 13, 2024
2 parents b5de53c + b1e8295 commit aa405ee
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .openapi-generator/oas_apivideo.yaml-defaut-cli.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0fe2cac0381637a3a558fb49517a143bede9af02a98487c03e3500dd6ce49387
cd016a70a1ba209dcbc81c7d3be841005121724ad28353ce785622c6a48a8d2a
2 changes: 1 addition & 1 deletion Sources/APIs/WebhooksAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class WebhooksAPI {
/**
Create Webhook
- POST /webhooks
- 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. * ```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``` This event occurs when a live stream is recorded and submitted for encoding.
- 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. * `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` 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.
- responseHeaders: [X-RateLimit-Limit(Int), X-RateLimit-Remaining(Int), X-RateLimit-Retry-After(Int)]
- parameter webhooksCreationPayload: (body)
- returns: RequestBuilder<Webhook>
Expand Down
12 changes: 10 additions & 2 deletions Sources/Models/Webhook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ import AnyCodable

public struct Webhook: Codable, Hashable {

public enum Events: String, Codable, CaseIterable {
case liveStreamBroadcastStarted = "live-stream.broadcast.started"
case liveStreamBroadcastEnded = "live-stream.broadcast.ended"
case videoSourceRecorded = "video.source.recorded"
case videoEncodingQualityCompleted = "video.encoding.quality.completed"
case videoCaptionGenerated = "video.caption.generated"
case videoSummaryGenerated = "video.summary.generated"
}
/** A unique identifier of the webhook you subscribed to. */
public var webhookId: String?
/** The time and date when you created this webhook subscription, in ATOM UTC format. */
public var createdAt: Date?
/** A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided. */
public var events: [String]?
public var events: [Events]?
/** The URL where the API sends the webhook. */
public var url: String?
/** A secret key for the webhook you subscribed to. You can use it to verify the origin of the webhook call that you receive. */
public var signatureSecret: String?

public init(webhookId: String? = nil, createdAt: Date? = nil, events: [String]? = nil, url: String? = nil, signatureSecret: String? = nil) {
public init(webhookId: String? = nil, createdAt: Date? = nil, events: [Events]? = nil, url: String? = nil, signatureSecret: String? = nil) {
self.webhookId = webhookId
self.createdAt = createdAt
self.events = events
Expand Down
14 changes: 11 additions & 3 deletions Sources/Models/WebhooksCreationPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ import AnyCodable

public struct WebhooksCreationPayload: Codable, Hashable {

/** 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. */
public var events: [String]
public enum Events: String, Codable, CaseIterable {
case liveStreamBroadcastStarted = "live-stream.broadcast.started"
case liveStreamBroadcastEnded = "live-stream.broadcast.ended"
case videoSourceRecorded = "video.source.recorded"
case videoEncodingQualityCompleted = "video.encoding.quality.completed"
case videoCaptionGenerated = "video.caption.generated"
case videoSummaryGenerated = "video.summary.generated"
}
/** An array of webhook events that you want to subscribe to. */
public var events: [Events]
/** The the url to which HTTP notifications are sent. It could be any http or https URL. */
public var url: String

public init(events: [String], url: String) {
public init(events: [Events], url: String) {
self.events = events
self.url = url
}
Expand Down
2 changes: 1 addition & 1 deletion docs/WebhooksAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Method | HTTP request | Description

Create Webhook

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. * ```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``` This event occurs when a live stream is recorded and submitted for encoding.
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. * `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` 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.


### Example
Expand Down
2 changes: 1 addition & 1 deletion docs/WebhooksCreationPayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**events** | **[String]** | A list of the webhooks that you are subscribing to. There are Currently four webhook options: * &#x60;&#x60;&#x60;video.encoding.quality.completed&#x60;&#x60;&#x60; 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 &#x60;&#x60;&#x60;{ \\\&quot;type\\\&quot;: \\\&quot;video.encoding.quality.completed\\\&quot;, \\\&quot;emittedAt\\\&quot;: \\\&quot;2021-01-29T16:46:25.217+01:00\\\&quot;, \\\&quot;videoId\\\&quot;: \\\&quot;viXXXXXXXX\\\&quot;, \\\&quot;encoding\\\&quot;: \\\&quot;hls\\\&quot;, \\\&quot;quality\\\&quot;: \\\&quot;720p\\\&quot;} &#x60;&#x60;&#x60;. This request says that the 720p HLS encoding was completed. * &#x60;&#x60;&#x60;live-stream.broadcast.started&#x60;&#x60;&#x60; When a live stream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires. * &#x60;&#x60;&#x60;live-stream.broadcast.ended&#x60;&#x60;&#x60; This event fires when a live stream has finished broadcasting. * &#x60;&#x60;&#x60;video.source.recorded&#x60;&#x60;&#x60; 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#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down

0 comments on commit aa405ee

Please sign in to comment.