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

com.twilio.sdk.resource.list.AddressList Maven / Gradle / Ivy

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

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;
import com.twilio.sdk.resource.ListResource;
import com.twilio.sdk.resource.factory.AddressFactory;
import com.twilio.sdk.resource.instance.Address;
import org.apache.http.NameValuePair;

import java.util.List;
import java.util.Map;

// TODO: Auto-generated Javadoc
/**
 * The Class AddressList.
 *
 *  For more information see https://www.twilio.com/docs/api/rest/address
 */
public class AddressList extends ListResource implements AddressFactory {

	/**
	 * Instantiates a new address list.
	 *
	 * @param client the client
	 */
	public AddressList(final TwilioRestClient client) {
		super(client);
	}

	/**
	 * Instantiates a new address list.
	 *
	 * @param client the client
	 * @param filters the filters
	 */
	public AddressList(final TwilioRestClient client, final Map filters) {
		super(client, filters);
	}

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

	/* (non-Javadoc)
	 * @see com.twilio.sdk.resource.ListResource#makeNew(com.twilio.sdk.TwilioRestClient, java.util.Map)
	 */
	@Override
	protected Address makeNew(final TwilioRestClient client,
	                             final Map params) {
		return new Address(client, params);
	}

	/* (non-Javadoc)
	 * @see com.twilio.sdk.resource.ListResource#getListKey()
	 */
	@Override
	protected String getListKey() {
		return "addresses";
	}

	public Address create(final Map params) throws TwilioRestException {
		TwilioRestResponse response = getClient().safeRequest(getResourceLocation(), "POST", params);
		return makeNew(getClient(), response.toMap());
	}

	public Address create(final List params) throws TwilioRestException {
		TwilioRestResponse response = getClient().safeRequest(getResourceLocation(), "POST", params
		);
		return makeNew(getClient(), response.toMap());
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy