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

com.twilio.sdk.resource.instance.Account Maven / Gradle / Ivy

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.resource.InstanceResource;
import com.twilio.sdk.resource.factory.*;
import com.twilio.sdk.resource.list.*;
import com.twilio.sdk.resource.factory.sip.*;
import com.twilio.sdk.resource.list.sip.*;
import com.twilio.sdk.resource.instance.sip.*;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;

// TODO: Auto-generated Javadoc
/**
 * The Class Account.
 *
 * For more information see https://www.twilio.com/docs/api/rest/account
 */
public class Account extends InstanceResource {

	/** The Constant DATE_UPDATED_PROPERTY. */
	private static final String DATE_UPDATED_PROPERTY = "date_updated";

	/** The Constant DATE_CREATED_PROPERTY. */
	private static final String DATE_CREATED_PROPERTY = "date_created";

	/** The Constant STATUS_PROPERTY. */
	private static final String STATUS_PROPERTY = "status";

	/** The Constant TYPE_PROPERTY. */
	private static final String TYPE_PROPERTY = "type";

	/** The Constant FRIENDLY_NAME_PROPERTY. */
	private static final String FRIENDLY_NAME_PROPERTY = "friendly_name";

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

	/** The Constant AUTH_TOKEN_PROPERTY. */
	private static final String AUTH_TOKEN_PROPERTY = "auth_token";

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

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

		Object ac = properties.get(ACCOUNT_SID_PROPERTY);
		if (ac != null && ac instanceof String) {
			String accountSid = (String) ac;
			this.setRequestAccountSid(accountSid);
		}

	}

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

	/**
	 * Sets the sid.
	 *
	 * @param accountSid
	 *            the new sid
   */
	public void setSid(String accountSid) {
		this.setRequestAccountSid(accountSid);
		this.setProperty(ACCOUNT_SID_PROPERTY, accountSid);
	}

	/**
	 * Gets the auth token.
	 *
	 * @return the auth token
   */
	public String getAuthToken() {
		return this.getProperty(AUTH_TOKEN_PROPERTY);
	}

	/**
	 * Sets the auth token.
	 *
	 * @param authToken
	 *            the new auth token
   */
	public void setAuthToken(String authToken) {
		this.setProperty(AUTH_TOKEN_PROPERTY, authToken);
	}

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

	/**
	 * Gets the status.
	 *
	 * @return the status
   */
	public String getStatus() {
		return this.getProperty(STATUS_PROPERTY);
	}

	/**
	 * Gets the account type
	 *
	 * @return the account type
   */
	public String getType() {
		return this.getProperty(TYPE_PROPERTY);
	}

	/**
	 * Gets the date created.
	 *
	 * @return the date created
   */
	public Date getDateCreated() {
		SimpleDateFormat format = new SimpleDateFormat(
				"EEE, dd MMM yyyy HH:mm:ss Z");
		try {
			return format.parse(this.getProperty(DATE_CREATED_PROPERTY));
		} catch (ParseException e) {
			return null;
		}
	}

	/**
	 * Gets the date updated.
	 *
	 * @return the date updated
   */
	public Date getDateUpdated() {
		SimpleDateFormat format = new SimpleDateFormat(
				"EEE, dd MMM yyyy HH:mm:ss Z");
		try {
			return format.parse(this.getProperty(DATE_UPDATED_PROPERTY));
		} catch (ParseException e) {
			return null;
		}
	}

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

	/*
	 * Subresource methods
   */
	/**
	 * Gets the calls list resource without any filters.
	 *
	 * https://www.twilio.com/docs/api/rest/call
	 *
	 * @return the calls
   */
	public CallList getCalls() {
		return this.getCalls(new HashMap());
	}

	/**
	 * Gets the calls list resource with the given filters.
	 *
	 * https://www.twilio.com/docs/api/rest/call
	 *
	 * @param filters
	 *            the filters
	 * @return the calls
   */
	public CallList getCalls(Map filters) {
		CallList calls = new CallList(this.getClient(), filters);
		calls.setRequestAccountSid(this.getRequestAccountSid());

		return calls;
	}

	/**
	 * Get a given call instance by sid
	 *
	 * @param sid The 34 character sid starting with CA
   */
	public Call getCall(String sid) {
		Call call = new Call(this.getClient(), sid);
		call.setRequestAccountSid(this.getRequestAccountSid());
		return call;
	}

	/**
	 * Gets the call factory, which lets you make outgoing calls.
	 *
	 * https://www.twilio.com/docs/api/rest/making_calls
	 *
	 * @return the call factory
   */
	public CallFactory getCallFactory() {
		return this.getCalls();
	}

	/**
	 * Gets the sms message list.
	 *
	 * https://www.twilio.com/docs/api/rest/sms
	 *
	 * @return the sms messages
   */
	public SmsList getSmsMessages() {
		return this.getSmsMessages(new HashMap());
	}

	/**
	 * Gets the sms messages list with the given filters
	 *
	 * https://www.twilio.com/docs/api/rest/sms
	 *
	 * @param filters
	 *            the filters
	 * @return the sms messages
   */
	public SmsList getSmsMessages(Map filters) {
		SmsList sms = new SmsList(this.getClient(), filters);
		sms.setRequestAccountSid(this.getRequestAccountSid());

		return sms;
	}

	/**
	 * Get a given sms instance by sid
	 * @param sid The 34 character sid starting with SM
   */
	public Sms getSms(String sid) {
		Sms sms = new Sms(this.getClient(), sid);
		sms.setRequestAccountSid(this.getRequestAccountSid());
		return sms;
	}

	/**
	 * Gets the sms factory which lets you send sms messages
	 *
	 * https://www.twilio.com/docs/api/rest/sending-sms
	 * @return the sms factory
   */
	public SmsFactory getSmsFactory() {
		return this.getSmsMessages();
	}

	/**
	 * Gets the message list.
	 *
	 * https://www.twilio.com/docs/api/rest/messages
	 *
	 * @return the messages
   */
	public MessageList getMessages() {
		return this.getMessages(new HashMap());
	}

	/**
	 * Gets the messages list with the given filters
	 *
	 * https://www.twilio.com/docs/api/rest/messages
	 *
	 * @param filters
	 *            the filters
	 * @return the messages
   */
	public MessageList getMessages(Map filters) {
		MessageList messages = new MessageList(this.getClient(), filters);
		messages.setRequestAccountSid(this.getRequestAccountSid());

		return messages;
	}

	/**
	 * Gets the message factory which lets you send messages
	 *
	 * https://www.twilio.com/docs/api/rest/sending-messages
	 * @return the message factory
   */
	public MessageFactory getMessageFactory() {
		return this.getMessages();
	}

	/**
	 * Get a given message instance by sid
	 * @param sid The 34 character sid starting with MM or SM
   */
	public Message getMessage(String sid) {
		Message message = new Message(this.getClient(), sid);
		message.setRequestAccountSid(this.getRequestAccountSid());
		return message;
	}

	/**
	 * Gets the media list.
	 *
	 * @return the media list
   */
	public MediaList getMedia() {
		return this.getMedia(new HashMap());
	}

	/**
	 * Gets the media list with the given filters.
	 *
	 * @return the media list
   */
	public MediaList getMedia(Map filters) {
		MediaList mediaList = new MediaList(this.getClient(), filters);
		mediaList.setRequestAccountSid(this.getRequestAccountSid());

		return mediaList;
	}


	/**
	 * Gets the media instance for this sid.
	 *
	 * @return the media
   */
	public Media getMedia(String sid) {
		Media media = new Media(this.getClient(), sid);
		media.setRequestAccountSid(this.getRequestAccountSid());
		return media;
	}

	/**
	 * Gets the application list
	 *
	 * https://www.twilio.com/docs/api/rest/applications
	 * @return the applications
   */
	public ApplicationList getApplications() {
		return this.getApplications(new HashMap());
	}

	/**
	 * Gets the application list with the given filters
	 *
	 * https://www.twilio.com/docs/api/rest/applications
	 *
	 * @param filters
	 *            the filters
	 * @return the applications
   */
	public ApplicationList getApplications(Map filters) {
		ApplicationList list = new ApplicationList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given application instance by sid
	 * @param sid The 34 character sid starting with AP
   */
	public Application getApplication(String sid) {
		Application app = new Application(this.getClient(), sid);
		app.setRequestAccountSid(this.getRequestAccountSid());
		return app;
	}


	/**
	 * Gets the application factory which lets you create new applications
	 *
	 * https://www.twilio.com/docs/api/rest/applications#list-post
	 *
	 * @return the application factory
   */
	public ApplicationFactory getApplicationFactory() {
		return this.getApplications();
	}



	/**
	 * Gets the available phone numbers. Defaults to US/Local
	 *
	 * See: https://www.twilio.com/docs/api/rest/available-phone-numbers
	 * @return the available phone numbers
   */
	public AvailablePhoneNumberList getAvailablePhoneNumbers() {
		return this.getAvailablePhoneNumbers(new HashMap());
	}

	/**
	 * Gets the available phone numbers. With the given search filters. Defaults
	 * to US/Local numbers
	 *
	 * See: https://www.twilio.com/docs/api/rest/available-phone-numbers
	 *
	 * @param filters
	 *            the filters
	 * @return the available phone numbers
   */
	public AvailablePhoneNumberList getAvailablePhoneNumbers(
			Map filters) {
		AvailablePhoneNumberList list = new AvailablePhoneNumberList(
				this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
			}

	/**
	 * Gets the available phone numbers with the given iso country and type
	 *
	 * See: https://www.twilio.com/docs/api/rest/available-phone-numbers
	 *
	 * @param filters
	 *            the filters
	 * @param isoCountry
	 *            the Iso Country code you are searching in
	 * @param type
	 *            the type of phone number. Possible values are
	 *            AvailablePhoneNumber.TYPE_LOCAL or
	 *            AvailablePhoneNumber.TYPE_TOLLFREE
	 *
	 * @return the available phone numbers
   */
	public AvailablePhoneNumberList getAvailablePhoneNumbers(
			Map filters, String isoCountry, String type) {
		AvailablePhoneNumberList list = new AvailablePhoneNumberList(
				this.getClient(), filters, isoCountry, type);
		list.setRequestAccountSid(this.getRequestAccountSid());

		return list;
			}

	/**
	 * Gets the conference list
	 *
	 * See: https://www.twilio.com/docs/api/rest/conference
	 *
	 * @return the conferences
   */
	public ConferenceList getConferences() {
		return this.getConferences(new HashMap());
	}

	/**
	 * Gets the conferences list with the given filters
	 *
	 * See: https://www.twilio.com/docs/api/rest/conference
	 *
	 * @param filters
	 *            the filters
	 * @return the conferences
   */
	public ConferenceList getConferences(Map filters) {
		ConferenceList list = new ConferenceList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given conference instance by sid
	 * @param sid The 34 character sid starting with CF
   */
	public Conference getConference(String sid) {
		Conference conf = new Conference(this.getClient(), sid);
		conf.setRequestAccountSid(this.getRequestAccountSid());
		return conf;
	}

	/**
	 * Gets the queue list
	 *
	 * See: https://www.twilio.com/docs/api/rest/queue
	 *
	 * @return the {@link QueueList}
   */
	public QueueList getQueues() {
		QueueList list = new QueueList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given queue by sid
	 *
	 * @param sid The Sid starting with QU
	 * @return the queue object
   */
	public Queue getQueue(String sid) {
		Queue queue = new Queue(this.getClient(), sid);
		queue.setRequestAccountSid(this.getRequestAccountSid());
		return queue;
	}

	/**
	 * Get the queue factory
   */
	public QueueFactory getQueueFactory() {
		return this.getQueues();
	}

	/**
	 * Gets the incoming phone numbers list
	 *
	 * See: https://www.twilio.com/docs/api/rest/incoming-phone-numbers
	 *
	 * @return the incoming phone numbers
   */
	public IncomingPhoneNumberList getIncomingPhoneNumbers() {
		return this.getIncomingPhoneNumbers(new HashMap());
	}

	/**
	 * Gets the incoming phone numbers list with the given filters
	 *
	 * See: https://www.twilio.com/docs/api/rest/incoming-phone-numbers
	 *
	 * @param filters
	 *            the filters
	 * @return the incoming phone numbers
   */
	public IncomingPhoneNumberList getIncomingPhoneNumbers(
			Map filters) {
		IncomingPhoneNumberList list = new IncomingPhoneNumberList(
				this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
			}

	/**
	 * Get a given incoming phone number instance by sid
	 * @param sid The 34 character sid starting with PN
   */
	public IncomingPhoneNumber getIncomingPhoneNumber(String sid) {
		IncomingPhoneNumber pn = new IncomingPhoneNumber(this.getClient(), sid);
		pn.setRequestAccountSid(this.getRequestAccountSid());
		return pn;
	}

	/**
	 * Gets the incoming phone number factory.
	 *
	 * See: https://www.twilio.com/docs/api/rest/incoming-phone-numbers#list-post
	 *
	 * @return the incoming phone number factory
   */
	public IncomingPhoneNumberFactory getIncomingPhoneNumberFactory() {
		return this.getIncomingPhoneNumbers();
	}

	/**
	 * Gets the shortcode list.
	 *
	 * @return the short code list
   */
	public ShortCodeList getShortCodes() {
		return this.getShortCodes(new HashMap());
	}

	/**
	 * Gets the short code list with filters
	 *
	 * @param filters
	 *            the filters
	 * @return the short code list
   */
	public ShortCodeList getShortCodes(Map filters) {
		ShortCodeList list = new ShortCodeList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given short code instance by sid
	 * @param sid The 34 character sid starting with SC
   */
	public ShortCode getShortCode(String sid) {
		ShortCode sc = new ShortCode(this.getClient(), sid);
		sc.setRequestAccountSid(this.getRequestAccountSid());
		return sc;
	}

	/**
	 * Gets the notifications.
	 *
	 * @return the notifications
   */
	public NotificationList getNotifications() {
		return this.getNotifications(new HashMap());
	}

	/**
	 * Gets the notifications.
	 *
	 * @param filters
	 *            the filters
	 * @return the notifications
   */
	public NotificationList getNotifications(Map filters) {
		NotificationList list = new NotificationList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given notification instance by sid
	 * @param sid The 34 character sid starting with NO
   */
	public Notification getNotification(String sid) {
		Notification n = new Notification(this.getClient(), sid);
		n.setRequestAccountSid(this.getRequestAccountSid());
		return n;
	}


	/**
	 * Gets the outgoing caller ids.
	 *
	 * https://www.twilio.com/docs/api/rest/outgoing-caller-ids
	 *
	 * @return the outgoing caller ids
   */
	public OutgoingCallerIdList getOutgoingCallerIds() {
		return this.getOutgoingCallerIds(new HashMap());
	}

	/**
	 * Gets the outgoing caller ids.
	 *
	 * https://www.twilio.com/docs/api/rest/outgoing-caller-ids
	 *
	 * @param filters
	 *            the filters
	 * @return the outgoing caller ids
   */
	public OutgoingCallerIdList getOutgoingCallerIds(Map filters) {
		OutgoingCallerIdList list = new OutgoingCallerIdList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given outgoing caller id instance by sid
	 * @param sid The 34 character sid starting with PN
   */
	public OutgoingCallerId getOutgoingCallerId(String sid) {
		OutgoingCallerId number = new OutgoingCallerId(this.getClient(), sid);
		number.setRequestAccountSid(this.getRequestAccountSid());
		return number;
	}



	/**
	 * Gets the outgoing caller id factory which lets you create outgoing caller ids
	 *
	 * https://www.twilio.com/docs/api/rest/outgoing-caller-ids
	 *
	 * @return the outgoing caller id factory
   */
	public OutgoingCallerIdFactory getOutgoingCallerIdFactory() {
		return this.getOutgoingCallerIds();
	}

	/**
	 * Gets the recordings list
	 *
	 * https://www.twilio.com/docs/api/rest/recording
	 *
	 * @return the recordings
   */
	public RecordingList getRecordings() {
		return this.getRecordings(new HashMap());
	}

	/**
	 * Gets the recordings list
	 *
	 * https://www.twilio.com/docs/api/rest/recording
	 *
	 * @param filters
	 *            the filters
	 * @return the recordings
   */
	public RecordingList getRecordings(Map filters) {
		RecordingList list = new RecordingList(this.getClient(), filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given recording instance by sid
	 * @param sid The 34 character sid starting with RE
   */
	public Recording getRecording(String sid) {
		Recording r = new Recording(this.getClient(), sid);
		r.setRequestAccountSid(this.getRequestAccountSid());
		return r;
	}

	/**
	 * Gets the transcriptions list
	 *
	 * https://www.twilio.com/docs/api/rest/transcription
	 *
	 * @return the transcriptions
   */
	public TranscriptionList getTranscriptions() {
		return this.getTranscriptions(new HashMap());
	}

	/**
	 * Gets the transcriptions list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/transcription
	 *
	 * @param filters
	 *            the filters
	 * @return the transcriptions
   */
	public TranscriptionList getTranscriptions(Map filters) {
		TranscriptionList list = new TranscriptionList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given transcription instance by sid
	 * @param sid The 34 character sid starting with TR
   */
	public Transcription getTranscription(String sid) {
		Transcription tr = new Transcription(this.getClient(), sid);
		tr.setRequestAccountSid(this.getRequestAccountSid());
		return tr;
	}

	/**
	 * Gets the Usage Record list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/usage-records
	 *
	 * @param filters
	 *            the filters
	 * @return the usage records
   */
	public UsageRecordList getUsageRecords(Map filters) {
		UsageRecordList list = new UsageRecordList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Gets the Usage Record list
	 *
	 * https://www.twilio.com/docs/api/rest/usage-records
	 *
	 * @return the usage records
   */
	public UsageRecordList getUsageRecords() {
		return this.getUsageRecords(new HashMap());
	}

	/**
	 * Get a specific Usage Trigger
   */
	public UsageTrigger getUsageTrigger(String sid) {
		UsageTrigger trigger = new UsageTrigger(this.getClient(), sid);
		trigger.setRequestAccountSid(this.getRequestAccountSid());
		return trigger;
	}

	/**
	 * Gets the Usage Trigger factory which lets you create usage triggers
	 *
	 * @return the usage trigger factory
   */
	public UsageTriggerFactory getUsageTriggerFactory() {
		return this.getUsageTriggers();
	}

	/**
	 * Gets the Usage Triggers list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/usage-triggers
	 *
	 * @param filters
	 *            the filters
	 * @return the usage records
   */
	public UsageTriggerList getUsageTriggers(Map filters) {
		UsageTriggerList list = new UsageTriggerList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Gets the Usage Triggers list
	 *
	 *  https://www.twilio.com/docs/api/rest/usage-triggers
	 *
	 * @return the usage triggers
   */
	public UsageTriggerList getUsageTriggers() {
		return this.getUsageTriggers(new HashMap());
	}

	/**
	 * Gets the connect app list
	 *
	 *  https://www.twilio.com/docs/api/rest/connect-apps
	 *
	 * @return the connect app list
   */
	public ConnectAppList getConnectApps() {
		return this.getConnectApps(new HashMap());
	}

	/**
	 * Gets the connect app list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/connect-apps
	 *
	 * @param filters
	 *            the filters
	 * @return the connect app list
   */
	public ConnectAppList getConnectApps(Map filters) {
		ConnectAppList list = new ConnectAppList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given connect app instance by sid
	 * @param sid The 34 character sid starting with CN
	 * @return the connect app
   */
	public ConnectApp getConnectApp(String sid) {
		ConnectApp cn = new ConnectApp(this.getClient(), sid);
		cn.setRequestAccountSid(this.getRequestAccountSid());
		return cn;
	}

	/**
	 * Gets the authorized connect app list
	 *
	 *  https://www.twilio.com/docs/api/rest/authorized-connect-apps
	 *
	 * @return the connect app list
   */
	public AuthorizedConnectAppList getAuthorizedConnectApps() {
		return this.getAuthorizedConnectApps(new HashMap());
	}

	/**
	 * Gets the authorized connect app list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/authorized-connect-apps
	 *
	 * @param filters
	 *            the filters
	 * @return the connect app list
   */
	public AuthorizedConnectAppList getAuthorizedConnectApps(Map filters) {
		AuthorizedConnectAppList list = new AuthorizedConnectAppList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given connect app instance by sid
	 * @param sid The 34 character sid starting with CN
	 * @return the connect app
   */
	public AuthorizedConnectApp getAuthorizedConnectApp(String sid) {
		AuthorizedConnectApp cn = new AuthorizedConnectApp(this.getClient(), sid);
		cn.setRequestAccountSid(this.getRequestAccountSid());
		return cn;
	}

    /**
     * Gets the sip domains list.
     *
	 *  https://www.twilio.com/docs/api/rest/sip-domains
     *
     * @return the sip domain
     */
    public DomainList getDomains() {
        return this.getDomains(new HashMap());
    }

	/**
	 * Gets the domain list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/sip-domains
	 *
	 * @param filters
	 *            the filters
	 * @return the sip domain list
	 */
	public DomainList getDomains(Map filters) {
		DomainList list = new DomainList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given sip domain instance by sid
	 * @param sid The 34 character sid starting with SD
	 * @return the sip domain
	 */
	public Domain getDomain(String sid) {
		Domain domain = new Domain(this.getClient(), sid);
		domain.setRequestAccountSid(this.getRequestAccountSid());
		return domain;
	}

	/**
	 * Gets a DomainFactory
	 * @return a DomainFactory that lets you create new Domains
	 */
	public DomainFactory getDomainFactory() {
		return this.getDomains();
	}

    /**
     * Gets the sip IpAccessControlLists list.
     *
	 *  https://www.twilio.com/docs/api/rest/sip-ip-access-control-lists
     *
     * @return the sip IpAccessControlList
     */
    public IpAccessControlListList getIpAccessControlLists() {
        return this.getIpAccessControlLists(new HashMap());
    }

	/**
	 * Gets the IpAccessControlList list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/sip-ip-access-control-lists
	 *
	 * @param filters
	 *            the filters
	 * @return the sip IpAccessControlList list
	 */
	public IpAccessControlListList getIpAccessControlLists(Map filters) {
		IpAccessControlListList list = new IpAccessControlListList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given IpAccessControlList instance by sid
	 * @param sid The 34 character sid starting with AL
	 * @return the sip IpAccessControlList
	 */
	public IpAccessControlList getIpAccessControlList(String sid) {
		IpAccessControlList ipAccessControlList = new IpAccessControlList(this.getClient(), sid);
		ipAccessControlList.setRequestAccountSid(this.getRequestAccountSid());
		return ipAccessControlList;
	}

	/**
	 * Gets an IpAccessControlListFactory
	 * @return an IpAccessControlListFactory that lets you create new IpAccessControlLists
	 */
	public IpAccessControlListFactory getIpAccessControlListFactory() {
		return this.getIpAccessControlLists();
	}

    /**
     * Gets the sip CredentialLists list.
     *
	 *  https://www.twilio.com/docs/api/rest/sip-credential-lists
     *
     * @return the sip CredentialList
     */
    public CredentialListList getCredentialLists() {
        return this.getCredentialLists(new HashMap());
    }

	/**
	 * Gets the CredentialList list with the given filters
	 *
	 *  https://www.twilio.com/docs/api/rest/sip-credential-lists
	 *
	 * @param filters
	 *            the filters
	 * @return the sip CredentialList list
	 */
	public CredentialListList getCredentialLists(Map filters) {
		CredentialListList list = new CredentialListList(this.getClient(),
				filters);
		list.setRequestAccountSid(this.getRequestAccountSid());
		return list;
	}

	/**
	 * Get a given CredentialList instance by sid
	 * @param sid The 34 character sid starting with AL
	 * @return the sip CredentialList
	 */
	public CredentialListInstance getCredentialList(String sid) {
		CredentialListInstance credentialList = new CredentialListInstance(this.getClient(), sid);
		credentialList.setRequestAccountSid(this.getRequestAccountSid());
		return credentialList;
	}

	/**
	 * Gets a CredentialListFactory
	 * @return the CredentialListFactory that lets you make new CredentialLists
	 */
	public CredentialListFactory getCredentialListFactory() {
		return this.getCredentialLists();
	}

	/**
	 * Get the developer sandbox
	 *
	 *  https://www.twilio.com/docs/api/rest/sandbox
	 * @return the sandbox
   */
	public Sandbox getSandbox() {
		Sandbox sb = new Sandbox(this.getClient());
		sb.setRequestAccountSid(this.getRequestAccountSid());
		return sb;
	}

	/**
	 * Close this subaccount. This will release all phone numbers assigned to it and shut it down completely.
	 * You will still have access to historical data for that subaccount, but you cannot reopen a closed account.
	 *
	 * @throws TwilioRestException
	 *             if there is an error in the request
	 * @return true, if successful
	 *
   */
	public boolean close() throws TwilioRestException {
		Map vars = new HashMap();
		vars.put("Status", "closed");
		TwilioRestResponse response = this.getClient().safeRequest(
				this.getResourceLocation(), "POST", vars);

		return !response.isError();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy