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 BasicInsightRequest extends BaseInsightRequest {
025    private BasicInsightRequest(Builder builder) {
026        this.number = builder.number;
027        this.country = builder.country;
028    }
029
030    /**
031     * Construct a BasicInsightRequest with a number.
032     *
033     * @param number A single phone number that you need insight about in national or international format.
034     *
035     * @return A new {@link BasicInsightRequest} object.
036     */
037    public static BasicInsightRequest withNumber(String number) {
038        return new Builder(number).build();
039    }
040
041    /**
042     * Construct a BasicInsightRequest with a number and country.
043     *
044     * @param number  A single phone number that you need insight about in national or international format.
045     * @param country If a number does not have a country code or it is uncertain, set the two-character country code.
046     *
047     * @return A new {@link BasicInsightRequest} object.
048     */
049    public static BasicInsightRequest withNumberAndCountry(String number, String country) {
050        return new Builder(number).country(country).build();
051    }
052
053    public static Builder builder(String number) {
054        return new Builder(number);
055    }
056
057    public static class Builder {
058        protected String number;
059        protected String country;
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         * @return A new {@link BasicInsightRequest} object from the stored builder options.
090         */
091        public BasicInsightRequest build() {
092            return new BasicInsightRequest(this);
093        }
094    }
095}