All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twilio.rest.api.v2010.account.incomingphonenumber.Local Maven / Gradle / Ivy

There is a newer version: 7.47.6
Show newest version
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.rest.api.v2010.account.incomingphonenumber;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.MoreObjects;
import com.twilio.base.Resource;
import com.twilio.converter.DateConverter;
import com.twilio.converter.Promoter;
import com.twilio.exception.ApiConnectionException;
import com.twilio.exception.ApiException;
import com.twilio.exception.RestException;
import com.twilio.http.HttpMethod;
import com.twilio.http.Request;
import com.twilio.http.Response;
import com.twilio.http.TwilioRestClient;
import com.twilio.rest.Domains;
import com.twilio.type.PhoneNumberCapabilities;
import org.joda.time.DateTime;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.Map;
import java.util.Objects;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Local extends Resource {
    private static final long serialVersionUID = 75964804463033L;

    public enum AddressRequirement {
        NONE("none"),
        ANY("any"),
        LOCAL("local"),
        FOREIGN("foreign");

        private final String value;

        private AddressRequirement(final String value) {
            this.value = value;
        }

        public String toString() {
            return value;
        }

        /**
         * Generate a AddressRequirement from a string.
         * @param value string value
         * @return generated AddressRequirement
         */
        @JsonCreator
        public static AddressRequirement forValue(final String value) {
            return Promoter.enumFromString(value, AddressRequirement.values());
        }
    }

    /**
     * Create a LocalReader to execute read.
     * 
     * @param pathAccountSid The account_sid
     * @return LocalReader capable of executing the read
     */
    public static LocalReader reader(final String pathAccountSid) {
        return new LocalReader(pathAccountSid);
    }

    /**
     * Create a LocalReader to execute read.
     * 
     * @return LocalReader capable of executing the read
     */
    public static LocalReader reader() {
        return new LocalReader();
    }

    /**
     * Create a LocalCreator to execute create.
     * 
     * @param pathAccountSid The account_sid
     * @param phoneNumber The phone number you want to purchase.
     * @return LocalCreator capable of executing the create
     */
    public static LocalCreator creator(final String pathAccountSid, 
                                       final com.twilio.type.PhoneNumber phoneNumber) {
        return new LocalCreator(pathAccountSid, phoneNumber);
    }

    /**
     * Create a LocalCreator to execute create.
     * 
     * @param phoneNumber The phone number you want to purchase.
     * @return LocalCreator capable of executing the create
     */
    public static LocalCreator creator(final com.twilio.type.PhoneNumber phoneNumber) {
        return new LocalCreator(phoneNumber);
    }

    /**
     * Converts a JSON String into a Local object using the provided ObjectMapper.
     * 
     * @param json Raw JSON String
     * @param objectMapper Jackson ObjectMapper
     * @return Local object represented by the provided JSON
     */
    public static Local fromJson(final String json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Local.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    /**
     * Converts a JSON InputStream into a Local object using the provided
     * ObjectMapper.
     * 
     * @param json Raw JSON InputStream
     * @param objectMapper Jackson ObjectMapper
     * @return Local object represented by the provided JSON
     */
    public static Local fromJson(final InputStream json, final ObjectMapper objectMapper) {
        // Convert all checked exceptions to Runtime
        try {
            return objectMapper.readValue(json, Local.class);
        } catch (final JsonMappingException | JsonParseException e) {
            throw new ApiException(e.getMessage(), e);
        } catch (final IOException e) {
            throw new ApiConnectionException(e.getMessage(), e);
        }
    }

    private final String accountSid;
    private final String addressSid;
    private final Local.AddressRequirement addressRequirements;
    private final String apiVersion;
    private final Boolean beta;
    private final PhoneNumberCapabilities capabilities;
    private final DateTime dateCreated;
    private final DateTime dateUpdated;
    private final String friendlyName;
    private final String identitySid;
    private final com.twilio.type.PhoneNumber phoneNumber;
    private final String origin;
    private final String sid;
    private final String smsApplicationSid;
    private final HttpMethod smsFallbackMethod;
    private final URI smsFallbackUrl;
    private final HttpMethod smsMethod;
    private final URI smsUrl;
    private final URI statusCallback;
    private final HttpMethod statusCallbackMethod;
    private final String trunkSid;
    private final String uri;
    private final String voiceApplicationSid;
    private final Boolean voiceCallerIdLookup;
    private final HttpMethod voiceFallbackMethod;
    private final URI voiceFallbackUrl;
    private final HttpMethod voiceMethod;
    private final URI voiceUrl;

    @JsonCreator
    private Local(@JsonProperty("account_sid")
                  final String accountSid, 
                  @JsonProperty("address_sid")
                  final String addressSid, 
                  @JsonProperty("address_requirements")
                  final Local.AddressRequirement addressRequirements, 
                  @JsonProperty("api_version")
                  final String apiVersion, 
                  @JsonProperty("beta")
                  final Boolean beta, 
                  @JsonProperty("capabilities")
                  final PhoneNumberCapabilities capabilities, 
                  @JsonProperty("date_created")
                  final String dateCreated, 
                  @JsonProperty("date_updated")
                  final String dateUpdated, 
                  @JsonProperty("friendly_name")
                  final String friendlyName, 
                  @JsonProperty("identity_sid")
                  final String identitySid, 
                  @JsonProperty("phone_number")
                  final com.twilio.type.PhoneNumber phoneNumber, 
                  @JsonProperty("origin")
                  final String origin, 
                  @JsonProperty("sid")
                  final String sid, 
                  @JsonProperty("sms_application_sid")
                  final String smsApplicationSid, 
                  @JsonProperty("sms_fallback_method")
                  final HttpMethod smsFallbackMethod, 
                  @JsonProperty("sms_fallback_url")
                  final URI smsFallbackUrl, 
                  @JsonProperty("sms_method")
                  final HttpMethod smsMethod, 
                  @JsonProperty("sms_url")
                  final URI smsUrl, 
                  @JsonProperty("status_callback")
                  final URI statusCallback, 
                  @JsonProperty("status_callback_method")
                  final HttpMethod statusCallbackMethod, 
                  @JsonProperty("trunk_sid")
                  final String trunkSid, 
                  @JsonProperty("uri")
                  final String uri, 
                  @JsonProperty("voice_application_sid")
                  final String voiceApplicationSid, 
                  @JsonProperty("voice_caller_id_lookup")
                  final Boolean voiceCallerIdLookup, 
                  @JsonProperty("voice_fallback_method")
                  final HttpMethod voiceFallbackMethod, 
                  @JsonProperty("voice_fallback_url")
                  final URI voiceFallbackUrl, 
                  @JsonProperty("voice_method")
                  final HttpMethod voiceMethod, 
                  @JsonProperty("voice_url")
                  final URI voiceUrl) {
        this.accountSid = accountSid;
        this.addressSid = addressSid;
        this.addressRequirements = addressRequirements;
        this.apiVersion = apiVersion;
        this.beta = beta;
        this.capabilities = capabilities;
        this.dateCreated = DateConverter.rfc2822DateTimeFromString(dateCreated);
        this.dateUpdated = DateConverter.rfc2822DateTimeFromString(dateUpdated);
        this.friendlyName = friendlyName;
        this.identitySid = identitySid;
        this.phoneNumber = phoneNumber;
        this.origin = origin;
        this.sid = sid;
        this.smsApplicationSid = smsApplicationSid;
        this.smsFallbackMethod = smsFallbackMethod;
        this.smsFallbackUrl = smsFallbackUrl;
        this.smsMethod = smsMethod;
        this.smsUrl = smsUrl;
        this.statusCallback = statusCallback;
        this.statusCallbackMethod = statusCallbackMethod;
        this.trunkSid = trunkSid;
        this.uri = uri;
        this.voiceApplicationSid = voiceApplicationSid;
        this.voiceCallerIdLookup = voiceCallerIdLookup;
        this.voiceFallbackMethod = voiceFallbackMethod;
        this.voiceFallbackUrl = voiceFallbackUrl;
        this.voiceMethod = voiceMethod;
        this.voiceUrl = voiceUrl;
    }

    /**
     * Returns The The unique id of the Account responsible for this phone number..
     * 
     * @return The unique id of the Account responsible for this phone number.
     */
    public final String getAccountSid() {
        return this.accountSid;
    }

    /**
     * Returns The The 34 character sid of the address associated with this number..
     * 
     * @return The 34 character sid of the address associated with this number.
     */
    public final String getAddressSid() {
        return this.addressSid;
    }

    /**
     * Returns The This indicates whether the phone number requires you or your
     * customer to have an Address registered with Twilio..
     * 
     * @return This indicates whether the phone number requires you or your
     *         customer to have an Address registered with Twilio.
     */
    public final Local.AddressRequirement getAddressRequirements() {
        return this.addressRequirements;
    }

    /**
     * Returns The Calls to this phone number will start a new TwiML session with
     * this API version..
     * 
     * @return Calls to this phone number will start a new TwiML session with this
     *         API version.
     */
    public final String getApiVersion() {
        return this.apiVersion;
    }

    /**
     * Returns The Phone numbers new to the Twilio platform are marked as beta..
     * 
     * @return Phone numbers new to the Twilio platform are marked as beta.
     */
    public final Boolean getBeta() {
        return this.beta;
    }

    /**
     * Returns The This is a set of boolean properties that indicate whether a phone
     * number can receive calls or messages..
     * 
     * @return This is a set of boolean properties that indicate whether a phone
     *         number can receive calls or messages.
     */
    public final PhoneNumberCapabilities getCapabilities() {
        return this.capabilities;
    }

    /**
     * Returns The The date that this resource was created, given as GMT RFC 2822
     * format..
     * 
     * @return The date that this resource was created, given as GMT RFC 2822
     *         format.
     */
    public final DateTime getDateCreated() {
        return this.dateCreated;
    }

    /**
     * Returns The The date that this resource was last updated, given as GMT RFC
     * 2822 format..
     * 
     * @return The date that this resource was last updated, given as GMT RFC 2822
     *         format.
     */
    public final DateTime getDateUpdated() {
        return this.dateUpdated;
    }

    /**
     * Returns The A human readable descriptive text for this resource, up to 64
     * characters long..
     * 
     * @return A human readable descriptive text for this resource, up to 64
     *         characters long.
     */
    public final String getFriendlyName() {
        return this.friendlyName;
    }

    /**
     * Returns The The identity_sid.
     * 
     * @return The identity_sid
     */
    public final String getIdentitySid() {
        return this.identitySid;
    }

    /**
     * Returns The The incoming phone number..
     * 
     * @return The incoming phone number.
     */
    public final com.twilio.type.PhoneNumber getPhoneNumber() {
        return this.phoneNumber;
    }

    /**
     * Returns The Twilio owned phone numbers are marked as twilio while hosted
     * phone numbers are marked as hosted..
     * 
     * @return Twilio owned phone numbers are marked as twilio while hosted phone
     *         numbers are marked as hosted.
     */
    public final String getOrigin() {
        return this.origin;
    }

    /**
     * Returns The A 34 character string that uniquely identifies this resource..
     * 
     * @return A 34 character string that uniquely identifies this resource.
     */
    public final String getSid() {
        return this.sid;
    }

    /**
     * Returns The The 34 character sid of the application Twilio should use to
     * handle SMSs sent to this number..
     * 
     * @return The 34 character sid of the application Twilio should use to handle
     *         SMSs sent to this number.
     */
    public final String getSmsApplicationSid() {
        return this.smsApplicationSid;
    }

    /**
     * Returns The The HTTP method Twilio will use when requesting the above URL..
     * 
     * @return The HTTP method Twilio will use when requesting the above URL.
     */
    public final HttpMethod getSmsFallbackMethod() {
        return this.smsFallbackMethod;
    }

    /**
     * Returns The The URL that Twilio will request if an error occurs retrieving or
     * executing the TwiML from SmsUrl..
     * 
     * @return The URL that Twilio will request if an error occurs retrieving or
     *         executing the TwiML from SmsUrl.
     */
    public final URI getSmsFallbackUrl() {
        return this.smsFallbackUrl;
    }

    /**
     * Returns The The HTTP method Twilio will use when making requests to the
     * SmsUrl..
     * 
     * @return The HTTP method Twilio will use when making requests to the SmsUrl.
     */
    public final HttpMethod getSmsMethod() {
        return this.smsMethod;
    }

    /**
     * Returns The The URL Twilio will request when receiving an incoming SMS
     * message to this number..
     * 
     * @return The URL Twilio will request when receiving an incoming SMS message
     *         to this number.
     */
    public final URI getSmsUrl() {
        return this.smsUrl;
    }

    /**
     * Returns The The URL that Twilio will request to pass status parameters to
     * your application..
     * 
     * @return The URL that Twilio will request to pass status parameters to your
     *         application.
     */
    public final URI getStatusCallback() {
        return this.statusCallback;
    }

    /**
     * Returns The The HTTP method Twilio will use to make requests to the
     * StatusCallback URL..
     * 
     * @return The HTTP method Twilio will use to make requests to the
     *         StatusCallback URL.
     */
    public final HttpMethod getStatusCallbackMethod() {
        return this.statusCallbackMethod;
    }

    /**
     * Returns The The 34 character sid of the Trunk Twilio should use to handle
     * phone calls to this number..
     * 
     * @return The 34 character sid of the Trunk Twilio should use to handle phone
     *         calls to this number.
     */
    public final String getTrunkSid() {
        return this.trunkSid;
    }

    /**
     * Returns The The URI for this resource, relative to https://api..
     * 
     * @return The URI for this resource, relative to https://api.
     */
    public final String getUri() {
        return this.uri;
    }

    /**
     * Returns The The 34 character sid of the application Twilio should use to
     * handle phone calls to this number..
     * 
     * @return The 34 character sid of the application Twilio should use to handle
     *         phone calls to this number.
     */
    public final String getVoiceApplicationSid() {
        return this.voiceApplicationSid;
    }

    /**
     * Returns The Look up the caller's caller-ID name from the CNAM database..
     * 
     * @return Look up the caller's caller-ID name from the CNAM database.
     */
    public final Boolean getVoiceCallerIdLookup() {
        return this.voiceCallerIdLookup;
    }

    /**
     * Returns The The HTTP method Twilio will use when requesting the
     * VoiceFallbackUrl..
     * 
     * @return The HTTP method Twilio will use when requesting the VoiceFallbackUrl.
     */
    public final HttpMethod getVoiceFallbackMethod() {
        return this.voiceFallbackMethod;
    }

    /**
     * Returns The The URL that Twilio will request if an error occurs retrieving or
     * executing the TwiML requested by Url..
     * 
     * @return The URL that Twilio will request if an error occurs retrieving or
     *         executing the TwiML requested by Url.
     */
    public final URI getVoiceFallbackUrl() {
        return this.voiceFallbackUrl;
    }

    /**
     * Returns The The HTTP method Twilio will use when requesting the above Url..
     * 
     * @return The HTTP method Twilio will use when requesting the above Url.
     */
    public final HttpMethod getVoiceMethod() {
        return this.voiceMethod;
    }

    /**
     * Returns The The URL Twilio will request when this phone number receives a
     * call..
     * 
     * @return The URL Twilio will request when this phone number receives a call.
     */
    public final URI getVoiceUrl() {
        return this.voiceUrl;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Local other = (Local) o;

        return Objects.equals(accountSid, other.accountSid) && 
               Objects.equals(addressSid, other.addressSid) && 
               Objects.equals(addressRequirements, other.addressRequirements) && 
               Objects.equals(apiVersion, other.apiVersion) && 
               Objects.equals(beta, other.beta) && 
               Objects.equals(capabilities, other.capabilities) && 
               Objects.equals(dateCreated, other.dateCreated) && 
               Objects.equals(dateUpdated, other.dateUpdated) && 
               Objects.equals(friendlyName, other.friendlyName) && 
               Objects.equals(identitySid, other.identitySid) && 
               Objects.equals(phoneNumber, other.phoneNumber) && 
               Objects.equals(origin, other.origin) && 
               Objects.equals(sid, other.sid) && 
               Objects.equals(smsApplicationSid, other.smsApplicationSid) && 
               Objects.equals(smsFallbackMethod, other.smsFallbackMethod) && 
               Objects.equals(smsFallbackUrl, other.smsFallbackUrl) && 
               Objects.equals(smsMethod, other.smsMethod) && 
               Objects.equals(smsUrl, other.smsUrl) && 
               Objects.equals(statusCallback, other.statusCallback) && 
               Objects.equals(statusCallbackMethod, other.statusCallbackMethod) && 
               Objects.equals(trunkSid, other.trunkSid) && 
               Objects.equals(uri, other.uri) && 
               Objects.equals(voiceApplicationSid, other.voiceApplicationSid) && 
               Objects.equals(voiceCallerIdLookup, other.voiceCallerIdLookup) && 
               Objects.equals(voiceFallbackMethod, other.voiceFallbackMethod) && 
               Objects.equals(voiceFallbackUrl, other.voiceFallbackUrl) && 
               Objects.equals(voiceMethod, other.voiceMethod) && 
               Objects.equals(voiceUrl, other.voiceUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accountSid,
                            addressSid,
                            addressRequirements,
                            apiVersion,
                            beta,
                            capabilities,
                            dateCreated,
                            dateUpdated,
                            friendlyName,
                            identitySid,
                            phoneNumber,
                            origin,
                            sid,
                            smsApplicationSid,
                            smsFallbackMethod,
                            smsFallbackUrl,
                            smsMethod,
                            smsUrl,
                            statusCallback,
                            statusCallbackMethod,
                            trunkSid,
                            uri,
                            voiceApplicationSid,
                            voiceCallerIdLookup,
                            voiceFallbackMethod,
                            voiceFallbackUrl,
                            voiceMethod,
                            voiceUrl);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                          .add("accountSid", accountSid)
                          .add("addressSid", addressSid)
                          .add("addressRequirements", addressRequirements)
                          .add("apiVersion", apiVersion)
                          .add("beta", beta)
                          .add("capabilities", capabilities)
                          .add("dateCreated", dateCreated)
                          .add("dateUpdated", dateUpdated)
                          .add("friendlyName", friendlyName)
                          .add("identitySid", identitySid)
                          .add("phoneNumber", phoneNumber)
                          .add("origin", origin)
                          .add("sid", sid)
                          .add("smsApplicationSid", smsApplicationSid)
                          .add("smsFallbackMethod", smsFallbackMethod)
                          .add("smsFallbackUrl", smsFallbackUrl)
                          .add("smsMethod", smsMethod)
                          .add("smsUrl", smsUrl)
                          .add("statusCallback", statusCallback)
                          .add("statusCallbackMethod", statusCallbackMethod)
                          .add("trunkSid", trunkSid)
                          .add("uri", uri)
                          .add("voiceApplicationSid", voiceApplicationSid)
                          .add("voiceCallerIdLookup", voiceCallerIdLookup)
                          .add("voiceFallbackMethod", voiceFallbackMethod)
                          .add("voiceFallbackUrl", voiceFallbackUrl)
                          .add("voiceMethod", voiceMethod)
                          .add("voiceUrl", voiceUrl)
                          .toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy