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.voice.ncco;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.JsonableBaseObject;
020import com.vonage.client.voice.EndpointType;
021
022/**
023 * Represents an app endpoint used in a {@link ConnectAction}. See
024 * <a href=https://developer.vonage.com/voice/voice-api/ncco-reference#app-endpoint>the documentation</a>
025 * for an example.
026 *
027 * @since 5.4.0
028 */
029public class AppEndpoint extends JsonableBaseObject implements Endpoint {
030    private final String user;
031
032    private AppEndpoint(Builder builder) {
033        this.user = builder.user;
034    }
035
036    @Override
037    public String getType() {
038        return EndpointType.APP.toString();
039    }
040
041    /**
042     * The user to connect to. This username must have been added as a user.
043     *
044     * @return The username.
045     */
046    @JsonProperty("user")
047    public String getUser() {
048        return user;
049    }
050
051    /**
052     * Entry point for constructing an instance of this class.
053     *
054     * @param user The username to connect to.
055     *
056     * @return A new Builder.
057     */
058    public static Builder builder(String user) {
059        return new Builder(user);
060    }
061
062    public static class Builder {
063        private String user;
064
065        Builder(String user) {
066            this.user = user;
067        }
068
069        @Deprecated
070        public Builder user(String user) {
071            this.user = user;
072            return this;
073        }
074
075        /**
076         * Builds the AppEndpoint.
077         *
078         * @return A new AppEndpoint with this builder's properties.
079         */
080        public AppEndpoint build() {
081            return new AppEndpoint(this);
082        }
083    }
084}