From b1e82954538e1f6c82636f8f5e19f66a699849ca Mon Sep 17 00:00:00 2001 From: szekelyzol Date: Wed, 13 Nov 2024 15:52:32 +0000 Subject: [PATCH] Add new webhooks --- .../oas_apivideo.yaml-defaut-cli.sha256 | 2 +- Sources/APIs/WebhooksAPI.swift | 2 +- Sources/Models/Webhook.swift | 12 ++++++++++-- Sources/Models/WebhooksCreationPayload.swift | 14 +++++++++++--- docs/WebhooksAPI.md | 2 +- docs/WebhooksCreationPayload.md | 2 +- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 b/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 index 659df4b..66589ce 100644 --- a/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 +++ b/.openapi-generator/oas_apivideo.yaml-defaut-cli.sha256 @@ -1 +1 @@ -0fe2cac0381637a3a558fb49517a143bede9af02a98487c03e3500dd6ce49387 \ No newline at end of file +cd016a70a1ba209dcbc81c7d3be841005121724ad28353ce785622c6a48a8d2a \ No newline at end of file diff --git a/Sources/APIs/WebhooksAPI.swift b/Sources/APIs/WebhooksAPI.swift index 7f980a9..2d49b2a 100644 --- a/Sources/APIs/WebhooksAPI.swift +++ b/Sources/APIs/WebhooksAPI.swift @@ -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 diff --git a/Sources/Models/Webhook.swift b/Sources/Models/Webhook.swift index c1d00d8..8c52cb6 100644 --- a/Sources/Models/Webhook.swift +++ b/Sources/Models/Webhook.swift @@ -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 diff --git a/Sources/Models/WebhooksCreationPayload.swift b/Sources/Models/WebhooksCreationPayload.swift index bd0c32d..85d41b9 100644 --- a/Sources/Models/WebhooksCreationPayload.swift +++ b/Sources/Models/WebhooksCreationPayload.swift @@ -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 } diff --git a/docs/WebhooksAPI.md b/docs/WebhooksAPI.md index 3be9bed..c68a160 100644 --- a/docs/WebhooksAPI.md +++ b/docs/WebhooksAPI.md @@ -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 diff --git a/docs/WebhooksCreationPayload.md b/docs/WebhooksCreationPayload.md index 432c60e..9d83a6e 100644 --- a/docs/WebhooksCreationPayload.md +++ b/docs/WebhooksCreationPayload.md @@ -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: * ```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#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)