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