001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.video;
017
018import com.fasterxml.jackson.annotation.JsonIgnore;
019import com.fasterxml.jackson.annotation.JsonProperty;
020import com.vonage.client.JsonableBaseObject;
021import java.util.Objects;
022
023public class SignalRequest extends JsonableBaseObject {
024        private final String type, data;
025        @JsonIgnore String sessionId;
026        @JsonIgnore String connectionId;
027
028        SignalRequest(Builder builder) {
029                this.type = Objects.requireNonNull(builder.type, "Type is required.");
030                this.data = Objects.requireNonNull(builder.data, "Data is required.");
031        }
032
033        /**
034         * @return The signal type.
035         */
036        @JsonProperty("type")
037        public String getType() {
038                return type;
039        }
040
041        /**
042         * @return The signal data.
043         */
044        @JsonProperty("data")
045        public String getData() {
046                return data;
047        }
048
049        /**
050         * Entry point for constructing an instance of SignalRequest.
051         *
052         * @return A new Builder.
053         */
054        public static Builder builder() {
055                return new Builder();
056        }
057        
058        public static class Builder {
059                private String type, data;
060        
061                Builder() {}
062        
063                /**
064                 * (REQUIRED)
065                 * Type of data that is being sent to the client. This cannot exceed 128 bytes.
066                 *
067                 * @param type The type as a string.
068                 * @return This builder.
069                 */
070                public Builder type(String type) {
071                        this.type = type;
072                        return this;
073                }
074
075                /**
076                 * (REQUIRED)
077                 * Payload that is being sent to the client. This cannot exceed 8 kilobytes.
078                 *
079                 * @param data The data as a string.
080                 * @return This builder.
081                 */
082                public Builder data(String data) {
083                        this.data = data;
084                        return this;
085                }
086        
087                /**
088                 * Builds the {@linkplain SignalRequest}.
089                 *
090                 * @return An instance of SignalRequest, populated with all fields from this builder.
091                 */
092                public SignalRequest build() {
093                        return new SignalRequest(this);
094                }
095        }
096}