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.numbers;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import java.net.URI;
020import java.util.UUID;
021
022/**
023 * Represents a number that is being rented by your account.
024 */
025public class OwnedNumber extends JsonableNumber {
026    private URI moHttpUrl;
027    private UpdateNumberRequest.CallbackType voiceCallbackType;
028    private String voiceCallbackValue;
029    private UUID appId, messagesCallbackValue;
030
031    /**
032     * Constructor, not for public use.
033     *
034     * @deprecated This will be made private in a future release.
035     */
036    @Deprecated
037    public OwnedNumber() {
038    }
039
040    /**
041     * URL of the webhook endpoint that handles inbound messages.
042     *
043     * @return The inbound message webhook URL as a string, or {@code null} if unspecified.
044     */
045    @JsonProperty("moHttpUrl")
046    public String getMoHttpUrl() {
047        return moHttpUrl != null ? moHttpUrl.toString() : null;
048    }
049
050    /**
051     * Voice webhook type. In a future release, this will be an enum.
052     *
053     * @return The voice webhook callback type as a string, or {@code null} if unknown.
054     */
055    @JsonProperty("voiceCallbackType")
056    public String getVoiceCallbackType() {
057        return voiceCallbackType != null ? voiceCallbackType.toString() : null;
058    }
059
060    /**
061     * SIP URI, telephone number or Application ID.
062     *
063     * @return The voice webhook value as a string, or {@code null} if unknown.
064     */
065    @JsonProperty("voiceCallbackValue")
066    public String getVoiceCallbackValue() {
067        return voiceCallbackValue;
068    }
069
070    /**
071     * Application ID for inbound message handling, if applicable.
072     *
073     * @return The application ID that will handle inbound messages to this number, or {@code null} if not applicable.
074     *
075     * @since 8.10.0
076     */
077    @JsonProperty("messagesCallbackValue")
078    public UUID getMessagesCallbackValue() {
079        return messagesCallbackValue;
080    }
081
082    /**
083     * ID of the application linked to this number, if applicable.
084     *
085     * @return The application UUID that this number is linked to, or {@code null} if not linked to any application.
086     * @since 8.12.0
087     */
088    @JsonProperty("app_id")
089    public UUID getAppId() {
090        return appId;
091    }
092
093    @Deprecated
094    public void setMoHttpUrl(String moHttpUrl) {
095        if (moHttpUrl != null) {
096            this.moHttpUrl = URI.create(moHttpUrl);
097        }
098    }
099
100    @Deprecated
101    public void setVoiceCallbackType(String voiceCallbackType) {
102        this.voiceCallbackType = UpdateNumberRequest.CallbackType.fromString(voiceCallbackType);
103    }
104
105    @Deprecated
106    public void setVoiceCallbackValue(String voiceCallbackValue) {
107        this.voiceCallbackValue = voiceCallbackValue;
108    }
109}