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