001/* 002 * Copyright (c) 2011-2017 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.insight; 023 024public class StandardInsightRequest extends BaseInsightRequest { 025 private StandardInsightRequest(Builder builder) { 026 this.number = builder.number; 027 this.country = builder.country; 028 this.cnam = builder.cnam; 029 } 030 031 public static Builder builder(String number) { 032 return new Builder(number); 033 } 034 035 public Boolean getCnam() { 036 return cnam; 037 } 038 039 /** 040 * Construct a StandardInsightRequest with a number. 041 * 042 * @param number A single phone number that you need insight about in national or international format. 043 * 044 * @return A new {@link StandardInsightRequest} object. 045 */ 046 public static StandardInsightRequest withNumber(String number) { 047 return new Builder(number).build(); 048 } 049 050 /** 051 * Construct a StandardInsightRequest with a number and country. 052 * 053 * @param number A single phone number that you need insight about in national or international format. 054 * @param country If a number does not have a country code or it is uncertain, set the two-character country code. 055 * 056 * @return A new {@link StandardInsightRequest} object. 057 */ 058 public static StandardInsightRequest withNumberAndCountry(String number, String country) { 059 return new Builder(number).country(country).build(); 060 } 061 062 public static class Builder { 063 protected String number; 064 protected String country; 065 protected Boolean cnam; 066 067 /** 068 * @param number A single phone number that you need insight about in national or international format. 069 */ 070 public Builder(String number) { 071 this.number = number; 072 } 073 074 /** 075 * @param number A single phone number that you need insight about in national or international format. 076 * 077 * @return The {@link Builder} to keep building. 078 */ 079 public Builder number(String number) { 080 this.number = number; 081 return this; 082 } 083 084 /** 085 * @param country If a number does not have a country code or it is uncertain, set the two-character country code. 086 * 087 * @return The {@link Builder} to keep building. 088 */ 089 public Builder country(String country) { 090 this.country = country; 091 return this; 092 } 093 094 /** 095 * @param cnam Indicates if the name of the person who owns the phone number should also be looked up and returned. 096 * Set to true to receive phone number owner name in the response. This is only available for US numbers 097 * and incurs an additional charge. 098 * 099 * @return The {@link Builder} to keep building. 100 */ 101 public Builder cnam(Boolean cnam) { 102 this.cnam = cnam; 103 return this; 104 } 105 106 /** 107 * @return A new {@link StandardInsightRequest} object from the stored builder options. 108 */ 109 public StandardInsightRequest build() { 110 return new StandardInsightRequest(this); 111 } 112 } 113}