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.application.capabilities; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import java.net.URI; 020 021/** 022 * Network APIs capability configuration settings. 023 * 024 * @since 8.12.0 025 */ 026public final class NetworkApis extends Capability { 027 private URI redirectUri; 028 private String networkApplicationId; 029 030 private NetworkApis() { 031 } 032 033 private NetworkApis(Builder builder) { 034 super(builder); 035 redirectUri = builder.redirectUri; 036 networkApplicationId = builder.networkApplicationId; 037 } 038 039 @Override 040 public Type getType() { 041 return Type.NETWORK; 042 } 043 044 /** 045 * Gets the Redirect URL. 046 * 047 * @return The redirect URI, or {@code null} if absent. 048 */ 049 @JsonProperty("redirect_uri") 050 public URI getRedirectUri() { 051 return redirectUri; 052 } 053 054 /** 055 * Gets the network application ID (this is different from the Vonage application ID). 056 * 057 * @return The network application ID as a string, or {@code null} if absent. 058 */ 059 @JsonProperty("network_application_id") 060 public String getNetworkApplicationId() { 061 return networkApplicationId; 062 } 063 064 /** 065 * Entry point for constructing an instance of this class. 066 * 067 * @return A new Builder. 068 */ 069 public static Builder builder() { 070 return new Builder(); 071 } 072 073 public static class Builder extends Capability.Builder<NetworkApis, Builder> { 074 private URI redirectUri; 075 private String networkApplicationId; 076 077 private Builder() {} 078 079 /** 080 * Sets the Redirect URL. 081 * 082 * @param redirectUri The redirect URL as a string. 083 * @return This builder. 084 */ 085 public Builder redirectUri(String redirectUri) { 086 return redirectUri(URI.create(redirectUri)); 087 } 088 089 /** 090 * Sets the Redirect URL. 091 * 092 * @param redirectUri The redirect URL. 093 * @return This builder. 094 */ 095 public Builder redirectUri(URI redirectUri) { 096 this.redirectUri = redirectUri; 097 return this; 098 } 099 100 /** 101 * Sets the network application ID (this is different from the Vonage application ID). 102 * 103 * @param networkApplicationId The network application ID as a string. 104 * @return This builder. 105 */ 106 public Builder networkApplicationId(String networkApplicationId) { 107 this.networkApplicationId = networkApplicationId; 108 return this; 109 } 110 111 /** 112 * Builds the NetworkApis object. 113 * 114 * @return A new Network APIs capability. 115 */ 116 @Override 117 public NetworkApis build() { 118 return new NetworkApis(this); 119 } 120 } 121}