001/* 002 * Copyright (c) 2011-2019 Nexmo Inc 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.nexmo.client.account; 023 024import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 025import com.fasterxml.jackson.annotation.JsonInclude; 026import com.fasterxml.jackson.annotation.JsonProperty; 027import com.fasterxml.jackson.databind.ObjectMapper; 028import com.nexmo.client.NexmoUnexpectedException; 029 030import java.io.IOException; 031 032@JsonInclude(JsonInclude.Include.NON_NULL) 033@JsonIgnoreProperties(ignoreUnknown = true) 034public class SettingsResponse { 035 @JsonProperty("mo-callback-url") 036 private String incomingSmsUrl; 037 @JsonProperty("dr-callback-url") 038 private String deliveryReceiptUrl; 039 @JsonProperty("max-outbound-request") 040 private Integer maxOutboundMessagesPerSecond; 041 @JsonProperty("max-inbound-request") 042 private Integer maxInboundMessagesPerSecond; 043 @JsonProperty("max-calls-per-second") 044 private Integer maxApiCallsPerSecond; 045 046 /** 047 * @return The URL where Nexmo will send a webhook when an incoming SMS is received when a number-specific URL is 048 * not configured. 049 */ 050 public String getIncomingSmsUrl() { 051 return incomingSmsUrl; 052 } 053 054 /** 055 * @return The URL where Nexmo will send a webhook when a delivery receipt is received when a number-specific URL is 056 * not configured. 057 */ 058 public String getDeliveryReceiptUrl() { 059 return deliveryReceiptUrl; 060 } 061 062 /** 063 * @return The maximum number of outbound messages per second. 064 */ 065 public Integer getMaxOutboundMessagesPerSecond() { 066 return maxOutboundMessagesPerSecond; 067 } 068 069 /** 070 * @return The maximum number of inbound messages per second. 071 */ 072 public Integer getMaxInboundMessagesPerSecond() { 073 return maxInboundMessagesPerSecond; 074 } 075 076 /** 077 * @return The maximum number of API calls per second. 078 */ 079 public Integer getMaxApiCallsPerSecond() { 080 return maxApiCallsPerSecond; 081 } 082 083 public static SettingsResponse fromJson(String json) { 084 try { 085 ObjectMapper mapper = new ObjectMapper(); 086 return mapper.readValue(json, SettingsResponse.class); 087 } catch (IOException e) { 088 throw new NexmoUnexpectedException("Failed to produce SettingsResponse from json.", e); 089 } 090 } 091}