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 BasicInsightRequest extends BaseInsightRequest { 019 private BasicInsightRequest(Builder builder) { 020 this.number = builder.number; 021 this.country = builder.country; 022 } 023 024 /** 025 * Construct a BasicInsightRequest with a number. 026 * 027 * @param number A single phone number that you need insight about in national or international format. 028 * 029 * @return A new {@link BasicInsightRequest} object. 030 */ 031 public static BasicInsightRequest withNumber(String number) { 032 return new Builder(number).build(); 033 } 034 035 /** 036 * Construct a BasicInsightRequest with a number and country. 037 * 038 * @param number A single phone number that you need insight about in national or international format. 039 * @param country If a number does not have a country code or it is uncertain, set the two-character country code. 040 * 041 * @return A new {@link BasicInsightRequest} object. 042 */ 043 public static BasicInsightRequest withNumberAndCountry(String number, String country) { 044 return new Builder(number).country(country).build(); 045 } 046 047 public static Builder builder(String number) { 048 return new Builder(number); 049 } 050 051 public static class Builder { 052 protected String number; 053 protected String country; 054 055 /** 056 * @param number A single phone number that you need insight about in national or international format. 057 */ 058 public Builder(String number) { 059 this.number = number; 060 } 061 062 /** 063 * @param number A single phone number that you need insight about in national or international format. 064 * 065 * @return The {@link Builder} to keep building. 066 */ 067 public Builder number(String number) { 068 this.number = number; 069 return this; 070 } 071 072 /** 073 * @param country If a number does not have a country code or it is uncertain, set the two-character country code. 074 * 075 * @return The {@link Builder} to keep building. 076 */ 077 public Builder country(String country) { 078 this.country = country; 079 return this; 080 } 081 082 /** 083 * @return A new {@link BasicInsightRequest} object from the stored builder options. 084 */ 085 public BasicInsightRequest build() { 086 return new BasicInsightRequest(this); 087 } 088 } 089}