diff --git a/api/openapi.yaml b/api/openapi.yaml index 6c80620..c7f3cd8 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -14706,17 +14706,20 @@ paths: x-accepts: application/json post: description: "Webhooks can push notifications to your server, rather than polling\ - \ api.video for changes. We currently offer four events: \n* ```video.encoding.quality.completed```\ + \ api.video for changes. We currently offer four events: \n* `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.\n* ```live-stream.broadcast.started```\ + } ```. This request says that the 720p HLS encoding was completed.\n* `live-stream.broadcast.started`\ \ When a live stream begins broadcasting, the broadcasting parameter changes\ - \ from false to true, and this webhook fires.\n* ```live-stream.broadcast.ended```\ - \ This event fires when a live stream has finished broadcasting.\n* ```video.source.recorded```\ - \ This event occurs when a live stream is recorded and submitted for encoding." + \ from false to true, and this webhook fires.\n* `live-stream.broadcast.ended`\ + \ This event fires when a live stream has finished broadcasting.\n* `video.source.recorded`\ + \ This event occurs when a live stream is recorded and submitted for encoding.\n\ + * `video.caption.generated` This event occurs when an automatic caption has\ + \ been generated.\n* `video.summary.generated` This event occurs when an\ + \ automatic summary has been generated." operationId: POST-webhooks requestBody: content: @@ -16362,6 +16365,13 @@ components: occur, the API triggers a webhook call to the URL you provided. example: '["video.encoding.quality.completed"]' items: + enum: + - live-stream.broadcast.started + - live-stream.broadcast.ended + - video.source.recorded + - video.encoding.quality.completed + - video.caption.generated + - video.summary.generated type: string type: array url: @@ -17889,15 +17899,17 @@ components: url: http://clientnotificationserver.com/notif?myquery=query properties: events: - description: |- - 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. + description: An array of webhook events that you want to subscribe to. example: - video.encoding.quality.completed items: + enum: + - live-stream.broadcast.started + - live-stream.broadcast.ended + - video.source.recorded + - video.encoding.quality.completed + - video.caption.generated + - video.summary.generated type: string type: array url: @@ -18897,4 +18909,153 @@ x-webhooks: summary: Accepted description: Your webhook server may return this response to api.video to signal that the webhook is accepted. + video.caption.generated: + post: + tags: + - Webhooks + summary: Video caption generated + description: This webhook triggers when the API finishes generating a caption + for a video. + operationId: POST-webhooks + parameters: + - in: header + name: X-Api-Video-WebhookID + schema: + type: string + description: The unique ID of your webhook. + required: true + - in: header + name: X-Api-Video-Signature + schema: + type: string + description: The webhook's body encrypted using the webhook's signature secret, + in HMAC SHA256. Use this hash to verify that api.video is the origin of + this webhook notification. + required: true + requestBody: + content: + application/json: + schema: + type: object + properties: + type: + type: string + description: The name of the webhook event that occurred. + example: video.caption.generated + emittedAt: + description: Returns the date-time when the webhook event occurred. + type: string + format: date-time + example: 2024-08-151T10:18:47+00:00 + videoId: + description: The ID of the video for which the caption was generated. + type: string + example: vi4blUQJFrYWbaG44NCh1234 + captionId: + description: The ID of the caption that was generated. + type: string + example: caption_1CHAfLFHT5B5EV4vzT1234 + generationMode: + description: Returns the method used to generate the caption. `transcript` + means that the caption was generated based on the transcription + of the video. Learn more about transcripts [here](https://docs.api.video/vod/generate-transcripts). + type: string + enum: + - transcript + example: transcript + language: + description: Returns the language of the captions in [IETF language + tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. + example: en + type: string + enum: + - ar + - ca + - cs + - da + - de + - el + - en + - es + - fa + - fi + - fr + - he + - hi + - hr + - hu + - it + - ja + - ko + - ml + - nl + - nn + - false + - pl + - pt + - ru + - sk + - sl + - te + - tr + - uk + - ur + - vi + - zh + responses: + "202": + summary: Accepted + description: Your webhook server may return this response to api.video to + signal that the webhook is accepted. + video.summary.generated: + post: + tags: + - Webhooks + summary: Video summary generated + description: This webhook triggers when the API finishes generating a summary + for a video. + operationId: POST-webhooks + parameters: + - in: header + name: X-Api-Video-WebhookID + schema: + type: string + description: The unique ID of your webhook. + required: true + - in: header + name: X-Api-Video-Signature + schema: + type: string + description: The webhook's body encrypted using the webhook's signature secret, + in HMAC SHA256. Use this hash to verify that api.video is the origin of + this webhook notification. + required: true + requestBody: + content: + application/json: + schema: + type: object + properties: + type: + type: string + description: The name of the webhook event that occurred. + example: video.caption.generated + emittedAt: + description: Returns the date-time when the webhook event occurred. + type: string + format: date-time + example: 2024-08-151T10:18:47+00:00 + videoId: + description: The ID of the video for which the summary was generated. + type: string + example: vi4blUQJFrYWbaG44NCh1234 + summaryId: + description: The ID of the summary that was generated. + type: string + example: summary_1CGyYoB9XCgBk4iQna8ocT + responses: + "202": + summary: Accepted + description: Your webhook server may return this response to api.video to + signal that the webhook is accepted. diff --git a/docs/Webhook.md b/docs/Webhook.md index 1aa8297..f0a03de 100644 --- a/docs/Webhook.md +++ b/docs/Webhook.md @@ -8,11 +8,24 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **webhookId** | **String** | A unique identifier of the webhook you subscribed to. | [optional] **createdAt** | **OffsetDateTime** | The time and date when you created this webhook subscription, in ATOM UTC format. | [optional] -**events** | **List<String>** | A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided. | [optional] +**events** | [**List<EventsEnum>**](#List<EventsEnum>) | A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided. | [optional] **url** | **String** | The URL where the API sends the webhook. | [optional] **signatureSecret** | **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. | [optional] + +## Enum: List<EventsEnum> + +Name | Value +---- | ----- +LIVE_STREAM_BROADCAST_STARTED | "live-stream.broadcast.started" +LIVE_STREAM_BROADCAST_ENDED | "live-stream.broadcast.ended" +VIDEO_SOURCE_RECORDED | "video.source.recorded" +VIDEO_ENCODING_QUALITY_COMPLETED | "video.encoding.quality.completed" +VIDEO_CAPTION_GENERATED | "video.caption.generated" +VIDEO_SUMMARY_GENERATED | "video.summary.generated" + + ## Implemented Interfaces * Serializable diff --git a/docs/WebhooksApi.md b/docs/WebhooksApi.md index 6335d14..fec5879 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 ```java @@ -38,11 +38,7 @@ public class Example { WebhooksApi apiInstance = client.webhooks(); WebhooksCreationPayload webhooksCreationPayload = new WebhooksCreationPayload(); // - webhooksCreationPayload.setEvents(Arrays.asList("video.encoding.quality.completed")); // 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. + webhooksCreationPayload.setEvents(Arrays.asList("video.encoding.quality.completed")); // An array of webhook events that you want to subscribe to. webhooksCreationPayload.setUrl("https://example.com/webhooks"); // The the url to which HTTP notifications are sent. It could be any http or https URL. diff --git a/docs/WebhooksCreationPayload.md b/docs/WebhooksCreationPayload.md index 659b6ac..56ba7ec 100644 --- a/docs/WebhooksCreationPayload.md +++ b/docs/WebhooksCreationPayload.md @@ -6,10 +6,23 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**events** | **List<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** | [**List<EventsEnum>**](#List<EventsEnum>) | 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. | + +## Enum: List<EventsEnum> + +Name | Value +---- | ----- +LIVE_STREAM_BROADCAST_STARTED | "live-stream.broadcast.started" +LIVE_STREAM_BROADCAST_ENDED | "live-stream.broadcast.ended" +VIDEO_SOURCE_RECORDED | "video.source.recorded" +VIDEO_ENCODING_QUALITY_COMPLETED | "video.encoding.quality.completed" +VIDEO_CAPTION_GENERATED | "video.caption.generated" +VIDEO_SUMMARY_GENERATED | "video.summary.generated" + + ## Implemented Interfaces * Serializable diff --git a/src/main/java/video/api/client/api/clients/WebhooksApi.java b/src/main/java/video/api/client/api/clients/WebhooksApi.java index 0a5d252..3b23331 100644 --- a/src/main/java/video/api/client/api/clients/WebhooksApi.java +++ b/src/main/java/video/api/client/api/clients/WebhooksApi.java @@ -203,18 +203,18 @@ private okhttp3.Call createValidateBeforeCall(WebhooksCreationPayload webhooksCr * 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\": + * 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. + * 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. * * @param webhooksCreationPayload * (required) @@ -272,18 +272,18 @@ public Webhook create(WebhooksCreationPayload webhooksCreationPayload) throws Ap * 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\": + * 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. + * 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. * * @param webhooksCreationPayload * (required) @@ -342,18 +342,18 @@ public ApiResponse createWithHttpInfo(WebhooksCreationPayload webhooksC /** * Create Webhook (asynchronously) 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\": + * 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. + * 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. * * @param webhooksCreationPayload * (required) diff --git a/src/main/java/video/api/client/api/models/Webhook.java b/src/main/java/video/api/client/api/models/Webhook.java index cbdfee7..d672ac1 100644 --- a/src/main/java/video/api/client/api/models/Webhook.java +++ b/src/main/java/video/api/client/api/models/Webhook.java @@ -41,9 +41,64 @@ public class Webhook implements Serializable, DeepObject { @SerializedName(SERIALIZED_NAME_CREATED_AT) private OffsetDateTime createdAt; + /** + * Gets or Sets events + */ + @JsonAdapter(EventsEnum.Adapter.class) + public enum EventsEnum { + LIVE_STREAM_BROADCAST_STARTED("live-stream.broadcast.started"), + + LIVE_STREAM_BROADCAST_ENDED("live-stream.broadcast.ended"), + + VIDEO_SOURCE_RECORDED("video.source.recorded"), + + VIDEO_ENCODING_QUALITY_COMPLETED("video.encoding.quality.completed"), + + VIDEO_CAPTION_GENERATED("video.caption.generated"), + + VIDEO_SUMMARY_GENERATED("video.summary.generated"); + + private String value; + + EventsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EventsEnum fromValue(String value) { + for (EventsEnum b : EventsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EventsEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EventsEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EventsEnum.fromValue(value); + } + } + } + public static final String SERIALIZED_NAME_EVENTS = "events"; @SerializedName(SERIALIZED_NAME_EVENTS) - private List events = null; + private List events = null; public static final String SERIALIZED_NAME_URL = "url"; @SerializedName(SERIALIZED_NAME_URL) @@ -95,12 +150,12 @@ public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; } - public Webhook events(List events) { + public Webhook events(List events) { this.events = events; return this; } - public Webhook addEventsItem(String eventsItem) { + public Webhook addEventsItem(EventsEnum eventsItem) { if (this.events == null) { this.events = new ArrayList<>(); } @@ -117,11 +172,11 @@ public Webhook addEventsItem(String eventsItem) { @javax.annotation.Nullable @ApiModelProperty(example = "[\"video.encoding.quality.completed\"]", value = "A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided.") - public List getEvents() { + public List getEvents() { return events; } - public void setEvents(List events) { + public void setEvents(List events) { this.events = events; } diff --git a/src/main/java/video/api/client/api/models/WebhooksCreationPayload.java b/src/main/java/video/api/client/api/models/WebhooksCreationPayload.java index ce0411f..ccabdfd 100644 --- a/src/main/java/video/api/client/api/models/WebhooksCreationPayload.java +++ b/src/main/java/video/api/client/api/models/WebhooksCreationPayload.java @@ -32,48 +32,91 @@ public class WebhooksCreationPayload implements Serializable, DeepObject { private static final long serialVersionUID = 1L; + /** + * Gets or Sets events + */ + @JsonAdapter(EventsEnum.Adapter.class) + public enum EventsEnum { + LIVE_STREAM_BROADCAST_STARTED("live-stream.broadcast.started"), + + LIVE_STREAM_BROADCAST_ENDED("live-stream.broadcast.ended"), + + VIDEO_SOURCE_RECORDED("video.source.recorded"), + + VIDEO_ENCODING_QUALITY_COMPLETED("video.encoding.quality.completed"), + + VIDEO_CAPTION_GENERATED("video.caption.generated"), + + VIDEO_SUMMARY_GENERATED("video.summary.generated"); + + private String value; + + EventsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EventsEnum fromValue(String value) { + for (EventsEnum b : EventsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EventsEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EventsEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EventsEnum.fromValue(value); + } + } + } + public static final String SERIALIZED_NAME_EVENTS = "events"; @SerializedName(SERIALIZED_NAME_EVENTS) - private List events = new ArrayList<>(); + private List events = new ArrayList<>(); public static final String SERIALIZED_NAME_URL = "url"; @SerializedName(SERIALIZED_NAME_URL) private String url; - public WebhooksCreationPayload events(List events) { + public WebhooksCreationPayload events(List events) { this.events = events; return this; } - public WebhooksCreationPayload addEventsItem(String eventsItem) { + public WebhooksCreationPayload addEventsItem(EventsEnum eventsItem) { this.events.add(eventsItem); return this; } /** - * 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. + * An array of webhook events that you want to subscribe to. * * @return events **/ - @ApiModelProperty(example = "[\"video.encoding.quality.completed\"]", required = true, value = "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.") + @ApiModelProperty(example = "[\"video.encoding.quality.completed\"]", required = true, value = "An array of webhook events that you want to subscribe to.") - public List getEvents() { + public List getEvents() { return events; } - public void setEvents(List events) { + public void setEvents(List events) { this.events = events; } diff --git a/src/test/java/video/api/client/api/clients/WebhooksApiTest.java b/src/test/java/video/api/client/api/clients/WebhooksApiTest.java index d83e247..ba69bb0 100644 --- a/src/test/java/video/api/client/api/clients/WebhooksApiTest.java +++ b/src/test/java/video/api/client/api/clients/WebhooksApiTest.java @@ -93,7 +93,7 @@ public void responseWithStatus200Test() throws ApiException { assertThat(res.getWebhookId()).isEqualTo("webhook_XXXXXXXXXXXXXXX"); assertThat(res.getCreatedAt()).isEqualTo("2021-01-08T14:12:18.000+00:00"); - assertThat(res.getEvents()).containsExactlyInAnyOrder("video.encoding.quality.completed"); + assertThat(res.getEvents()).containsExactlyInAnyOrder(Webhook.EventsEnum.VIDEO_ENCODING_QUALITY_COMPLETED); assertThat(res.getUrl()).isEqualTo("http://clientnotificationserver.com/notif?myquery=query"); } } @@ -128,12 +128,12 @@ public void responseWithStatus200Test() throws ApiException { assertThat(page.getItems()).containsExactlyInAnyOrder( new Webhook().webhookId("webhook_XXXXXXXXXXXXXXX") .createdAt(OffsetDateTime.parse("2021-01-08T14:12:18.000+00:00")) - .addEventsItem("video.encoding.quality.completed") + .addEventsItem(Webhook.EventsEnum.VIDEO_ENCODING_QUALITY_COMPLETED) .url("http://clientnotificationserver.com/notif?myquery=query") .signatureSecret("sig_sec_Abcd12348RLP7VPLi7nYVh"), new Webhook().webhookId("webhook_XXXXXXXXXYYYYYY") .createdAt(OffsetDateTime.parse("2021-01-12T12:12:12.000+00:00")) - .addEventsItem("video.encoding.quality.completed") + .addEventsItem(Webhook.EventsEnum.VIDEO_ENCODING_QUALITY_COMPLETED) .url("http://clientnotificationserver.com/notif?myquery=query2") .signatureSecret("sig_sec_Abcd12358RLP7VPLi7nYVy")); } diff --git a/src/test/java/video/api/integration/WebhooksTest.java b/src/test/java/video/api/integration/WebhooksTest.java index 76d4bad..a6639d1 100644 --- a/src/test/java/video/api/integration/WebhooksTest.java +++ b/src/test/java/video/api/integration/WebhooksTest.java @@ -25,10 +25,9 @@ public class WebhooksTest extends AbstractTest { @Order(1) @DisplayName("create a webhook") public void createWebhook() throws ApiException { - this.webhook = apiClient.webhooks() - .create(new WebhooksCreationPayload() - .events(Collections.singletonList("video.encoding.quality.completed")) - .url("https://webhooks.test-java-api-client.fr")); + this.webhook = apiClient.webhooks().create(new WebhooksCreationPayload() + .events(Collections.singletonList(WebhooksCreationPayload.EventsEnum.VIDEO_ENCODING_QUALITY_COMPLETED)) + .url("https://webhooks.test-java-api-client.fr")); assertThat(webhook.getWebhookId()).isNotNull(); }