Skip to content

Commit 8e7d524

Browse files
author
Doug Black
committed
cast safeRequest
1 parent 37fed6b commit 8e7d524

File tree

8 files changed

+141
-133
lines changed

8 files changed

+141
-133
lines changed

src/main/java/com/twilio/sdk/resource/InstanceResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,12 @@ protected Date parseDate(String inDate) {
140140
if (inDate==null) {
141141
return null;
142142
}
143+
SimpleDateFormat format = new SimpleDateFormat(
144+
"EEE, dd MMM yyyy HH:mm:ss Z");
145+
try {
146+
return format.parse(inDate);
147+
} catch (ParseException e) {
148+
return null;
149+
}
150+
}
143151
}

src/main/java/com/twilio/sdk/resource/instance/sip/Address.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public String getIpAddress() {
149149
*/
150150
public boolean delete() throws TwilioRestException {
151151
TwilioRestResponse response = this.getClient().safeRequest(
152-
this.getResourceLocation(), "DELETE", null);
152+
this.getResourceLocation(), "DELETE", (Map) null);
153153

154154
return !response.isError();
155155
}

src/main/java/com/twilio/sdk/resource/instance/sip/Credential.java

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414

1515
public class Credential extends InstanceResource {
1616

17-
/** The Constant SID_PROPERTY. */
18-
private static final String SID_PROPERTY = "sid";
19-
private String requestCredentialListSid;
20-
21-
/**
22-
* Instantiates a new Credential.
23-
*
24-
* @param client the client
25-
*/
26-
public Credential(TwilioRestClient client) {
27-
super(client);
28-
}
29-
30-
/**
31-
* Instantiates a new Credential.
32-
*
33-
* @param client the client
34-
* @param sid the sid
35-
*/
36-
public Credential(TwilioRestClient client, String credentialListSid, String sid) {
37-
super(client);
38-
if (sid == null) {
39-
throw new IllegalStateException("The Sid for a Credential can not be null");
40-
}
41-
this.setProperty(SID_PROPERTY, sid);
42-
this.requestCredentialListSid = credentialListSid;
43-
}
17+
/** The Constant SID_PROPERTY. */
18+
private static final String SID_PROPERTY = "sid";
19+
private String requestCredentialListSid;
20+
21+
/**
22+
* Instantiates a new Credential.
23+
*
24+
* @param client the client
25+
*/
26+
public Credential(TwilioRestClient client) {
27+
super(client);
28+
}
29+
30+
/**
31+
* Instantiates a new Credential.
32+
*
33+
* @param client the client
34+
* @param sid the sid
35+
*/
36+
public Credential(TwilioRestClient client, String credentialListSid, String sid) {
37+
super(client);
38+
if (sid == null) {
39+
throw new IllegalStateException("The Sid for a Credential can not be null");
40+
}
41+
this.setProperty(SID_PROPERTY, sid);
42+
this.requestCredentialListSid = credentialListSid;
43+
}
4444

4545
/**
4646
* Instantiates a new Credential.
@@ -56,13 +56,13 @@ public Credential(TwilioRestClient client, Map<String, Object> properties) {
5656
* @see com.twilio.sdk.resource.Resource#getResourceLocation()
5757
*/
5858
@Override
59-
protected String getResourceLocation() {
60-
return "/" + TwilioRestClient.DEFAULT_VERSION
61-
+ "/Accounts/" + this.getRequestAccountSid()
62-
+ "/SIP/CredentialLists/" + this.getRequestCredentialListSid()
63-
+ "/Credentials/" + this.getSid()
64-
+ ".json";
65-
}
59+
protected String getResourceLocation() {
60+
return "/" + TwilioRestClient.DEFAULT_VERSION
61+
+ "/Accounts/" + this.getRequestAccountSid()
62+
+ "/SIP/CredentialLists/" + this.getRequestCredentialListSid()
63+
+ "/Credentials/" + this.getSid()
64+
+ ".json";
65+
}
6666

6767
/*
6868
* Property getters
@@ -125,26 +125,26 @@ public String getUsername() {
125125
return this.getProperty("username");
126126
}
127127

128-
/**
129-
* Gets the sid of the parent credential list
130-
*
131-
* @return the credential list sid
132-
*/
133-
public String getRequestCredentialListSid() {
134-
return this.requestCredentialListSid;
135-
}
136-
137-
/**
138-
* Delete this {@link Credential}.
139-
* @throws TwilioRestException
140-
* if there is an error in the request
141-
* @return true, if successful
142-
*
143-
*/
144-
public boolean delete() throws TwilioRestException {
145-
TwilioRestResponse response = this.getClient().safeRequest(
146-
this.getResourceLocation(), "DELETE", null);
147-
148-
return !response.isError();
149-
}
128+
/**
129+
* Gets the sid of the parent credential list
130+
*
131+
* @return the credential list sid
132+
*/
133+
public String getRequestCredentialListSid() {
134+
return this.requestCredentialListSid;
135+
}
136+
137+
/**
138+
* Delete this {@link Credential}.
139+
* @throws TwilioRestException
140+
* if there is an error in the request
141+
* @return true, if successful
142+
*
143+
*/
144+
public boolean delete() throws TwilioRestException {
145+
TwilioRestResponse response = this.getClient().safeRequest(
146+
this.getResourceLocation(), "DELETE", (Map) null);
147+
148+
return !response.isError();
149+
}
150150
}

src/main/java/com/twilio/sdk/resource/instance/sip/CredentialListInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Credential getCredential(String credentialSid) {
165165
*/
166166
public boolean delete() throws TwilioRestException {
167167
TwilioRestResponse response = this.getClient().safeRequest(
168-
this.getResourceLocation(), "DELETE", null);
168+
this.getResourceLocation(), "DELETE", (Map) null);
169169

170170
return !response.isError();
171171
}

src/main/java/com/twilio/sdk/resource/instance/sip/CredentialListMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public String getFriendlyName() {
142142
*/
143143
public boolean delete() throws TwilioRestException {
144144
TwilioRestResponse response = this.getClient().safeRequest(
145-
this.getResourceLocation(), "DELETE", null);
145+
this.getResourceLocation(), "DELETE", (Map) null);
146146

147147
return !response.isError();
148148
}

src/main/java/com/twilio/sdk/resource/instance/sip/Domain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public CredentialListMappingFactory getCredentialListMappingFactory() {
275275
*/
276276
public boolean delete() throws TwilioRestException {
277277
TwilioRestResponse response = this.getClient().safeRequest(
278-
this.getResourceLocation(), "DELETE", null);
278+
this.getResourceLocation(), "DELETE", (Map) null);
279279

280280
return !response.isError();
281281
}

src/main/java/com/twilio/sdk/resource/instance/sip/IpAccessControlList.java

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@
1616

1717
public class IpAccessControlList extends InstanceResource {
1818

19-
/** The Constant SID_PROPERTY. */
20-
private static final String SID_PROPERTY = "sid";
21-
22-
/**
23-
* Instantiates a new IpAccessControlList.
24-
*
25-
* @param client the client
26-
*/
27-
public IpAccessControlList(TwilioRestClient client) {
28-
super(client);
29-
}
30-
31-
/**
32-
* Instantiates a new IpAccessControlList.
33-
*
34-
* @param client the client
35-
* @param sid the sid
36-
*/
37-
public IpAccessControlList(TwilioRestClient client, String sid) {
38-
super(client);
39-
if (sid == null) {
40-
throw new IllegalStateException("The Sid for a IpAccessControlList can not be null");
41-
}
42-
this.setProperty(SID_PROPERTY, sid);
43-
}
19+
/** The Constant SID_PROPERTY. */
20+
private static final String SID_PROPERTY = "sid";
21+
22+
/**
23+
* Instantiates a new IpAccessControlList.
24+
*
25+
* @param client the client
26+
*/
27+
public IpAccessControlList(TwilioRestClient client) {
28+
super(client);
29+
}
30+
31+
/**
32+
* Instantiates a new IpAccessControlList.
33+
*
34+
* @param client the client
35+
* @param sid the sid
36+
*/
37+
public IpAccessControlList(TwilioRestClient client, String sid) {
38+
super(client);
39+
if (sid == null) {
40+
throw new IllegalStateException("The Sid for a IpAccessControlList can not be null");
41+
}
42+
this.setProperty(SID_PROPERTY, sid);
43+
}
4444

4545
/**
4646
* Instantiates a new IpAccessControlList.
@@ -56,11 +56,11 @@ public IpAccessControlList(TwilioRestClient client, Map<String, Object> properti
5656
* @see com.twilio.sdk.resource.Resource#getResourceLocation()
5757
*/
5858
@Override
59-
protected String getResourceLocation() {
60-
return "/" + TwilioRestClient.DEFAULT_VERSION + "/Accounts/"
59+
protected String getResourceLocation() {
60+
return "/" + TwilioRestClient.DEFAULT_VERSION + "/Accounts/"
6161
+ this.getRequestAccountSid() + "/SIP/IpAccessControlLists/" + this.getSid()
6262
+ ".json";
63-
}
63+
}
6464

6565
/*
6666
* Property getters
@@ -123,48 +123,48 @@ public String getFriendlyName() {
123123
return this.getProperty("friendly_name");
124124
}
125125

126-
/**
127-
* Gets the ip addresses on this list.
128-
*
129-
* @return an AddressList of the addresses on this list
130-
*/
131-
public AddressList getAddresses() {
132-
AddressList addressList = new AddressList(this.getClient(), this.getSid());
133-
addressList.setRequestAccountSid(this.getRequestAccountSid());
134-
return addressList;
135-
}
136-
137-
/**
138-
* Gets the address factory, which lets you make new addresses.
139-
*
140-
* @return an AddressList of the addresses on this list
141-
*/
142-
public AddressFactory getAddressFactory() {
143-
return this.getAddresses();
144-
}
145-
146-
/**
147-
* Gets the ip addresses on this list.
148-
*
149-
* @return an AddressList of the addresses on this list
150-
*/
151-
public Address getAddress(String addressSid) {
152-
Address address = new Address(this.getClient(), this.getSid(), addressSid);
153-
address.setRequestAccountSid(this.getRequestAccountSid());
154-
return address;
155-
}
156-
157-
/**
158-
* Delete this {@link IpAccessControlList}.
159-
* @throws TwilioRestException
160-
* if there is an error in the request
161-
* @return true, if successful
162-
*
163-
*/
164-
public boolean delete() throws TwilioRestException {
165-
TwilioRestResponse response = this.getClient().safeRequest(
166-
this.getResourceLocation(), "DELETE", null);
167-
168-
return !response.isError();
169-
}
126+
/**
127+
* Gets the ip addresses on this list.
128+
*
129+
* @return an AddressList of the addresses on this list
130+
*/
131+
public AddressList getAddresses() {
132+
AddressList addressList = new AddressList(this.getClient(), this.getSid());
133+
addressList.setRequestAccountSid(this.getRequestAccountSid());
134+
return addressList;
135+
}
136+
137+
/**
138+
* Gets the address factory, which lets you make new addresses.
139+
*
140+
* @return an AddressList of the addresses on this list
141+
*/
142+
public AddressFactory getAddressFactory() {
143+
return this.getAddresses();
144+
}
145+
146+
/**
147+
* Gets the ip addresses on this list.
148+
*
149+
* @return an AddressList of the addresses on this list
150+
*/
151+
public Address getAddress(String addressSid) {
152+
Address address = new Address(this.getClient(), this.getSid(), addressSid);
153+
address.setRequestAccountSid(this.getRequestAccountSid());
154+
return address;
155+
}
156+
157+
/**
158+
* Delete this {@link IpAccessControlList}.
159+
* @throws TwilioRestException
160+
* if there is an error in the request
161+
* @return true, if successful
162+
*
163+
*/
164+
public boolean delete() throws TwilioRestException {
165+
TwilioRestResponse response = this.getClient().safeRequest(
166+
this.getResourceLocation(), "DELETE", (Map) null);
167+
168+
return !response.isError();
169+
}
170170
}

src/main/java/com/twilio/sdk/resource/instance/sip/IpAccessControlListMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public String getFriendlyName() {
142142
*/
143143
public boolean delete() throws TwilioRestException {
144144
TwilioRestResponse response = this.getClient().safeRequest(
145-
this.getResourceLocation(), "DELETE", null);
145+
this.getResourceLocation(), "DELETE", (Map) null);
146146

147147
return !response.isError();
148148
}

0 commit comments

Comments
 (0)