Skip to content

Commit ba0bfa7

Browse files
author
Doug Black
committed
merge master
2 parents ef7ef17 + 10fa4b8 commit ba0bfa7

File tree

5 files changed

+71
-26
lines changed

5 files changed

+71
-26
lines changed

src/main/java/com/twilio/sdk/resource/instance/UsageTrigger.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ public String getUri() {
220220
return getProperty("Uri");
221221
}
222222

223+
/**
224+
* Get the account sid
225+
*
226+
* @return account sid
227+
*/
228+
public String getAccountSid() {
229+
return getProperty("AccountSid");
230+
}
231+
223232
/**
224233
* Delete
225234
*

src/main/java/com/twilio/sdk/resource/list/UsageTriggerList.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,39 @@ public UsageTriggerList(TwilioRestClient client,
3939
* @see com.twilio.sdk.resource.Resource#getResourceLocation()
4040
*/
4141
@Override
42-
protected String getResourceLocation() {
43-
return "/" + TwilioRestClient.DEFAULT_VERSION + "/Accounts/"
44-
+ this.getRequestAccountSid() + "/Usage/Triggers";
45-
}
42+
protected String getResourceLocation() {
43+
return "/" + TwilioRestClient.DEFAULT_VERSION + "/Accounts/"
44+
+ this.getRequestAccountSid() + "/Usage/Triggers";
45+
}
4646

4747
/* (non-Javadoc)
4848
* @see com.twilio.sdk.resource.ListResource#makeNew(com.twilio.sdk.TwilioRestClient, java.util.Map)
4949
*/
5050
@Override
51-
protected UsageTrigger makeNew(TwilioRestClient client,
52-
Map<String, Object> properties) {
53-
return new UsageTrigger(client, properties);
54-
}
51+
protected UsageTrigger makeNew(TwilioRestClient client,
52+
Map<String, Object> properties) {
53+
return new UsageTrigger(client, properties);
54+
}
5555

5656
/* (non-Javadoc)
5757
* @see com.twilio.sdk.resource.ListResource#getListKey()
5858
*/
5959
@Override
60-
protected String getListKey() {
61-
return "UsageTriggers";
62-
}
60+
protected String getListKey() {
61+
return "UsageTriggers";
62+
}
6363

6464
@Override
65-
public UsageTrigger create(Map<String, String> params) throws TwilioRestException {
66-
TwilioRestResponse response = this.getClient().safeRequest(
67-
this.getResourceLocation(), "POST", params);
68-
return makeNew(this.getClient(), (Map<String, Object>) response.toMap().get("UsageTrigger"));
69-
}
65+
public UsageTrigger create(Map<String, String> params) throws TwilioRestException {
66+
TwilioRestResponse response = this.getClient().safeRequest(
67+
this.getResourceLocation(), "POST", params);
68+
return makeNew(this.getClient(), (Map<String, Object>) response.toMap().get("UsageTriggers"));
69+
}
7070

7171
@Override
72-
public UsageTrigger create(List<NameValuePair> params) throws TwilioRestException {
73-
TwilioRestResponse response = this.getClient().safeRequest(
74-
this.getResourceLocation(), "POST", params);
75-
return makeNew(this.getClient(), (Map<String, Object>) response.toMap().get("UsageTrigger"));
76-
}
72+
public UsageTrigger create(List<NameValuePair> params) throws TwilioRestException {
73+
TwilioRestResponse response = this.getClient().safeRequest(
74+
this.getResourceLocation(), "POST", params);
75+
return makeNew(this.getClient(), (Map<String, Object>) response.toMap().get("UsageTriggers"));
76+
}
7777
}

src/main/java/com/twilio/sdk/verbs/Sip.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ public class Sip extends Verb {
88
/**
99
* Instantiates a new Sip.
1010
*/
11-
public Sip() {
12-
super(V_SIP, null);
11+
public Sip(final String uri) {
12+
super(V_SIP, uri);
1313
this.allowedVerbs = new ArrayList<String>();
1414
this.allowedVerbs.add(Verb.V_URI);
1515
}
1616

17+
/**
18+
* Instantiates a new Sip Noun with no URI.
19+
*/
20+
public Sip() {
21+
this(null);
22+
}
23+
1724
public void setUsername(String username) {
1825
this.set("username", username);
1926
}

src/main/java/com/twilio/sdk/verbs/Uri.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.twilio.sdk.verbs;
22

3-
import java.util.ArrayList;
4-
53
public class Uri extends Verb {
64

7-
85
/**
96
* Instantiates a new Uri to dial with Sip
107
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.twilio.sdk.verbs;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class SipTest {
8+
9+
/**
10+
* Test the SIP noun with a text element representing the URI.
11+
*/
12+
@Test
13+
public void testBasicSip() {
14+
Sip sip = new Sip("sip:alice@twilio.com;transport=udp");
15+
assertEquals("<Sip>sip:alice@twilio.com;transport=udp</Sip>", sip.toXML());
16+
}
17+
18+
/**
19+
* Test the SIP noun with a child URI noun.
20+
* @throws TwiMLException
21+
*/
22+
@Test
23+
public void testSipUriNoun() throws TwiMLException {
24+
Sip sip = new Sip();
25+
Uri uri = new Uri("sip:alice@twilio.com;transport=udp");
26+
uri.setUsername("alice");
27+
uri.setPassword("hellotwilio");
28+
sip.append(uri);
29+
assertEquals("<Sip><Uri username=\"alice\" password=\"hellotwilio\">sip:alice@twilio.com;transport=udp</Uri></Sip>",
30+
sip.toXML());
31+
}
32+
}

0 commit comments

Comments
 (0)