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.insight;
017
018public class BasicInsightRequest extends BaseInsightRequest {
019
020    private BasicInsightRequest(Builder builder) {
021        super(builder.number, 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 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 BasicInsightRequest object.
042     */
043    public static BasicInsightRequest withNumberAndCountry(String number, String country) {
044        return new Builder(number).country(country).build();
045    }
046
047    /**
048     * This method is the starting point for constructing a Basic Insight request.
049     *
050     * @param number A single phone number that you need insight about in national or international format.
051     *
052     * @return A new {@link Builder} instance.
053     */
054    public static Builder builder(String number) {
055        return new Builder(number);
056    }
057
058    /**
059     * This method is the starting point for constructing a Basic Insight request.
060     * Note that the number field must be set.
061     *
062     * @return A new {@link Builder} instance.
063     */
064    public static Builder builder() {
065        return new Builder();
066    }
067
068    public static class Builder {
069        protected String number, country;
070
071        protected Builder(String number) {
072            this.number = number;
073        }
074
075        protected Builder() {}
076
077        /**
078         * @param number A single phone number that you need insight about in national or international format.
079         *
080         * @return This builder.
081         */
082        public Builder number(String number) {
083            this.number = number;
084            return this;
085        }
086
087        /**
088         * @param country If a number does not have a country code, or it is uncertain, set the two-character country code.
089         *
090         * @return This builder.
091         */
092        public Builder country(String country) {
093            this.country = country;
094            return this;
095        }
096
097        /**
098         * @return A new {@link BasicInsightRequest} object from the stored builder options.
099         */
100        public BasicInsightRequest build() {
101            return new BasicInsightRequest(this);
102        }
103    }
104}