Skip to content

Commit

Permalink
Adding delete() to IncomingPhoneNumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
frankstratton committed Aug 11, 2011
1 parent 541c8b0 commit f804c43
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/java/com/twilio/sdk/examples/RestExamples.java
Expand Up @@ -47,7 +47,6 @@ public static void main(String[] args) throws TwilioRestException {
// Get the main account (The one we used to authenticate the client
Account mainAccount = client.getAccount();


// Get all accounts including sub accounts
AccountList accountList = client.getAccounts();

Expand Down
91 changes: 59 additions & 32 deletions src/java/com/twilio/sdk/resource/instance/IncomingPhoneNumber.java
Expand Up @@ -6,33 +6,40 @@
import java.util.Map;

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

// TODO: Auto-generated Javadoc
/**
* The Class IncomingPhoneNumber.
*
* For more information see {@see <a href="http://www.twilio.com/docs/api/rest/incoming-phone-numbers">http://www.twilio.com/docs/api/rest/incoming-phone-numbers}
* For more information see {@see <a
* href="http://www.twilio.com/docs/api/rest/incoming-phone-numbers"
* >http://www.twilio.com/docs/api/rest/incoming-phone-numbers}
*/
public class IncomingPhoneNumber extends InstanceResource {

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

/**
* Instantiates a new incoming phone number.
*
* @param client the client
*
* @param client
* the client
*/
public IncomingPhoneNumber(TwilioRestClient client) {
super(client);
}

/**
* Instantiates a new incoming phone number.
*
* @param client the client
* @param sid the sid
*
* @param client
* the client
* @param sid
* the sid
*/
public IncomingPhoneNumber(TwilioRestClient client, String sid) {
super(client);
Expand All @@ -41,16 +48,20 @@ public IncomingPhoneNumber(TwilioRestClient client, String sid) {

/**
* Instantiates a new incoming phone number.
*
* @param client the client
* @param properties the properties
*
* @param client
* the client
* @param properties
* the properties
*/
public IncomingPhoneNumber(TwilioRestClient client,
Map<String, Object> properties) {
super(client, properties);
}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see com.twilio.sdk.resource.Resource#getResourceLocation()
*/
@Override
Expand All @@ -60,12 +71,28 @@ protected String getResourceLocation() {
+ this.getSid() + ".json";
}

/**
* Deprovision this IncomingPhoneNumber. This will remove it from your
* account.
*
* @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", null);

return !response.isError();
}

/*
* Property getters
*/
/**
* Gets the sid.
*
*
* @return the sid
*/
public String getSid() {
Expand All @@ -74,7 +101,7 @@ public String getSid() {

/**
* Gets the date created.
*
*
* @return the date created
*/
public Date getDateCreated() {
Expand All @@ -89,7 +116,7 @@ public Date getDateCreated() {

/**
* Gets the date updated.
*
*
* @return the date updated
*/
public Date getDateUpdated() {
Expand All @@ -104,7 +131,7 @@ public Date getDateUpdated() {

/**
* Gets the friendly name.
*
*
* @return the friendly name
*/
public String getFriendlyName() {
Expand All @@ -113,7 +140,7 @@ public String getFriendlyName() {

/**
* Gets the account sid.
*
*
* @return the account sid
*/
public String getAccountSid() {
Expand All @@ -122,7 +149,7 @@ public String getAccountSid() {

/**
* Gets the phone number.
*
*
* @return the phone number
*/
public String getPhoneNumber() {
Expand All @@ -131,7 +158,7 @@ public String getPhoneNumber() {

/**
* Gets the voice applicaiton sid.
*
*
* @return the voice applicaiton sid
*/
public String getVoiceApplicaitonSid() {
Expand All @@ -140,7 +167,7 @@ public String getVoiceApplicaitonSid() {

/**
* Gets the sms applicaiton sid.
*
*
* @return the sms applicaiton sid
*/
public String getSmsApplicaitonSid() {
Expand All @@ -149,7 +176,7 @@ public String getSmsApplicaitonSid() {

/**
* Gets the api version.
*
*
* @return the api version
*/
public String getApiVersion() {
Expand All @@ -158,7 +185,7 @@ public String getApiVersion() {

/**
* Gets the voice url.
*
*
* @return the voice url
*/
public String getVoiceUrl() {
Expand All @@ -167,7 +194,7 @@ public String getVoiceUrl() {

/**
* Gets the voice method.
*
*
* @return the voice method
*/
public String getVoiceMethod() {
Expand All @@ -176,7 +203,7 @@ public String getVoiceMethod() {

/**
* Gets the voice fallback url.
*
*
* @return the voice fallback url
*/
public String getVoiceFallbackUrl() {
Expand All @@ -185,7 +212,7 @@ public String getVoiceFallbackUrl() {

/**
* Gets the voice fallback method.
*
*
* @return the voice fallback method
*/
public String getVoiceFallbackMethod() {
Expand All @@ -194,7 +221,7 @@ public String getVoiceFallbackMethod() {

/**
* Gets the status callback.
*
*
* @return the status callback
*/
public String getStatusCallback() {
Expand All @@ -203,7 +230,7 @@ public String getStatusCallback() {

/**
* Gets the status callback method.
*
*
* @return the status callback method
*/
public String getStatusCallbackMethod() {
Expand All @@ -212,7 +239,7 @@ public String getStatusCallbackMethod() {

/**
* Gets the voice caller id lookup.
*
*
* @return the voice caller id lookup
*/
public String getVoiceCallerIdLookup() {
Expand All @@ -221,7 +248,7 @@ public String getVoiceCallerIdLookup() {

/**
* Gets the sms url.
*
*
* @return the sms url
*/
public String getSmsUrl() {
Expand All @@ -230,7 +257,7 @@ public String getSmsUrl() {

/**
* Gets the sms method.
*
*
* @return the sms method
*/
public String getSmsMethod() {
Expand All @@ -239,7 +266,7 @@ public String getSmsMethod() {

/**
* Gets the sms fallback url.
*
*
* @return the sms fallback url
*/
public String getSmsFallbackUrl() {
Expand All @@ -248,7 +275,7 @@ public String getSmsFallbackUrl() {

/**
* Gets the sms fallback method.
*
*
* @return the sms fallback method
*/
public String getSmsFallbackMethod() {
Expand All @@ -257,7 +284,7 @@ public String getSmsFallbackMethod() {

/**
* Gets the sms status callback.
*
*
* @return the sms status callback
*/
public String getSmsStatusCallback() {
Expand Down

0 comments on commit f804c43

Please sign in to comment.