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.account;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.QueryParamsRequest;
020import java.util.LinkedHashMap;
021import java.util.Map;
022
023/**
024 * Request wrapper for updating account settings.
025 *
026 * @deprecated This will be made package-private in the next major release.
027 */
028@Deprecated
029public class SettingsRequest implements QueryParamsRequest {
030    private final String incomingSmsUrl, deliveryReceiptUrl;
031
032    /**
033     * Constructor.
034     *
035     * @param incomingSmsUrl     The URL where Vonage will send a webhook when an incoming SMS is received when a
036     *                           number-specific URL is not configured. Set to an empty string to unset the value.
037     * @param deliveryReceiptUrl The URL where Vonage will send a webhook when an incoming SMS is received when a
038     *                           number-specific URL is not configured. Set to an empty string to unset the value.
039     */
040    public SettingsRequest(String incomingSmsUrl, String deliveryReceiptUrl) {
041        this.incomingSmsUrl = incomingSmsUrl;
042        this.deliveryReceiptUrl = deliveryReceiptUrl;
043    }
044
045    /**
046     * @param incomingSmsUrl The URL where Vonage will send a webhook when an incoming SMS is received when a
047     *                       number-specific URL is not configured. Set to an empty string to unset the value.
048     *
049     * @return An SettingsRequest with only the incoming SMS URL set.
050     * @deprecated This will be removed in the next major release.
051     */
052    @Deprecated
053    public static SettingsRequest withIncomingSmsUrl(String incomingSmsUrl) {
054        return new SettingsRequest(incomingSmsUrl, null);
055    }
056
057    /**
058     * @param deliveryReceiptUrl The URL where Vonage will send a webhook when an incoming SMS is received when a
059     *                           number-specific URL is not configured. Set to an empty string to unset the value.
060     *
061     * @return An SettingsRequest with only the delivery receipt URL set.
062     * @deprecated This will be removed in the next major release.
063     */
064    @Deprecated
065    public static SettingsRequest withDeliveryReceiptUrl(String deliveryReceiptUrl) {
066        return new SettingsRequest(null, deliveryReceiptUrl);
067    }
068
069    /**
070     * @return The URL where Vonage will send a webhook when an incoming SMS is received when a number-specific URL is
071     * not configured.
072     */
073    public String getIncomingSmsUrl() {
074        return incomingSmsUrl;
075    }
076
077    /**
078     * @return The URL where Vonage will send a webhook when a delivery receipt is received when a number-specific URL is
079     * not configured.
080     */
081    public String getDeliveryReceiptUrl() {
082        return deliveryReceiptUrl;
083    }
084
085    @Override
086    public Map<String, String> makeParams() {
087        Map<String, String> params = new LinkedHashMap<>(4);
088        if (incomingSmsUrl != null) {
089            params.put("moCallBackUrl", incomingSmsUrl);
090        }
091        if (deliveryReceiptUrl != null) {
092            params.put("drCallBackUrl", deliveryReceiptUrl);
093        }
094        return params;
095    }
096}