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

com.twilio.sdk.resource.instance.sip.IpAddress Maven / Gradle / Ivy

There is a newer version: 7.0.0-rc-10
Show newest version
package com.twilio.sdk.resource.instance.sip;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;
import com.twilio.sdk.resource.InstanceResource;

import java.util.Date;
import java.util.Map;

public class IpAddress extends InstanceResource {

	/** The Constant SID_PROPERTY. */
	private static final String SID_PROPERTY = "sid";
	private String ipAccessControlListSid;

	/**
	 * Instantiates a new IpAddress.
	 *
	 * @param client the client
	 */
	public IpAddress(TwilioRestClient client) {
		super(client);
	}

	/**
	 * Instantiates a new IpAddress.
	 *
	 * @param client the client
	 * @param ipAccessControlListSid the sid of list this IpAddress belongs to
	 * @param sid the sid
	 */
	public IpAddress(TwilioRestClient client, String ipAccessControlListSid, String sid) {
		super(client);
		if (sid == null) {
			throw new IllegalStateException("The Sid for an IpAddress can not be null");
		}
		if (ipAccessControlListSid == null) {
			throw new IllegalStateException("The Sid for an ip access control list can not be null");
		}
		this.setProperty(SID_PROPERTY, sid);
		this.ipAccessControlListSid = ipAccessControlListSid;
	}

	/**
	 * Instantiates a new IpAddress.
	 *
	 * @param client the client
	 * @param properties the properties
	 */
	public IpAddress(TwilioRestClient client, Map properties) {
		super(client, properties);
	}

	/* (non-Javadoc)
	 * @see com.twilio.sdk.resource.Resource#getResourceLocation()
	 */
	@Override
		protected String getResourceLocation() {
			return "/" + TwilioRestClient.DEFAULT_VERSION
				+ "/Accounts/" + this.getRequestAccountSid()
				+ "/SIP/IpAccessControlLists/" + this.getIpAccessControlListSid()
				+ "/IpAddresses/" + this.getSid() + ".json";
		}

	/*
	 * Property getters
	 */

	/**
	 * Gets the sid.
	 *
	 * @return the sid
	 */
	public String getSid() {
		return this.getProperty(SID_PROPERTY);
	}

	public String getIpAccessControlListSid() {
		return this.ipAccessControlListSid;
	}

	/**
	 * Gets the date created.
	 *
	 * @return the date created
	 */
	public Date getDateCreated() {
		return getDateProperty("date_created");
	}

	/**
	 * Gets the date updated.
	 *
	 * @return the date updated
	 */
	public Date getDateUpdated() {
		return getDateProperty("date_updated");
	}

	/**
	 * Gets the account sid.
	 *
	 * @return the account sid
	 */
	public String getAccountSid() {
		return this.getProperty("account_sid");
	}

	/**
	 * Gets the friendly name
	 *
	 * @return the friendly name
	 */
	public String getFriendlyName() {
		return this.getProperty("friendly_name");
	}

	/**
	 * Gets the ip IpAddress
	 *
	 * @return the friendly name
	 */
	public String getIpAddress() {
		return this.getProperty("ip_address");
	}

	/**
	 * Delete this {@link IpAddress}.
	 * @throws TwilioRestException
	 *             if there is an error in the request
	 * @return true, if successful
	 *
	 */
	public boolean delete() throws TwilioRestException {
		TwilioRestResponse response = this.getClient().safeRequest(
				this.getResourceLocation(), "DELETE", (Map) null);

		return !response.isError();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy