Skip to content

Commit 44f4d6f

Browse files
committed
Use factory methods in example
1 parent cfb6971 commit 44f4d6f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/main/java/com/twilio/example/Example.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22

33

44
import com.twilio.Twilio;
5-
import com.twilio.rest.api.v2010.account.CallCreator;
6-
import com.twilio.rest.api.v2010.account.IncomingPhoneNumberCreator;
7-
import com.twilio.rest.api.v2010.account.MessageCreator;
8-
import com.twilio.rest.trunking.v1.TrunkCreator;
9-
import com.twilio.rest.api.v2010.account.CallReader;
10-
import com.twilio.rest.api.v2010.account.MessageReader;
11-
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.LocalReader;
125
import com.twilio.rest.api.v2010.account.Call;
6+
import com.twilio.rest.api.v2010.account.CallCreator;
137
import com.twilio.rest.api.v2010.account.IncomingPhoneNumber;
148
import com.twilio.rest.api.v2010.account.Message;
159
import com.twilio.rest.api.v2010.account.availablephonenumbercountry.Local;
1610
import com.twilio.rest.notify.v1.Service;
1711
import com.twilio.rest.trunking.v1.Trunk;
18-
import com.twilio.type.PhoneNumber;
12+
import com.twilio.rest.trunking.v1.TrunkCreator;
1913
import com.twilio.twiml.Play;
2014
import com.twilio.twiml.Say;
2115
import com.twilio.twiml.TwiML;
2216
import com.twilio.twiml.TwiMLException;
2317
import com.twilio.twiml.VoiceResponse;
18+
import com.twilio.type.PhoneNumber;
2419

2520
import java.net.URI;
2621
import java.util.Iterator;
@@ -47,7 +42,7 @@ public static void main(String[] args) throws TwiMLException {
4742
System.out.println(number.getPhoneNumber());
4843

4944
// Send a text message
50-
Message message = new MessageCreator(
45+
Message message = Message.creator(
5146
ACCOUNT_SID,
5247
PHONE_NUMBER,
5348
number.getPhoneNumber(),
@@ -67,14 +62,14 @@ public static void main(String[] args) throws TwiMLException {
6762
System.out.println(call.getSid());
6863

6964
// Print all the messages
70-
Iterable<Message> messages = new MessageReader().read();
65+
Iterable<Message> messages = Message.reader().read();
7166
for (Message m : messages) {
7267
System.out.println(m.getSid());
7368
System.out.println(m.getBody());
7469
}
7570

7671
// Get some calls
77-
Iterable<Call> calls = new CallReader().pageSize(2).read();
72+
Iterable<Call> calls = Call.reader().pageSize(2).read();
7873
for (Call c : calls) {
7974
System.out.println(c.getSid());
8075
}
@@ -108,13 +103,13 @@ public static void main(String[] args) throws TwiMLException {
108103

109104
private static IncomingPhoneNumber buyNumber() {
110105
// Look up some phone numbers
111-
Iterable<Local> numbers = new LocalReader(ACCOUNT_SID, "US").read();
106+
Iterable<Local> numbers = Local.reader(ACCOUNT_SID, "US").read();
112107

113108
// Buy the first phone number
114109
Iterator<Local> iter = numbers.iterator();
115110
if (iter.hasNext()) {
116111
Local local = iter.next();
117-
return new IncomingPhoneNumberCreator(
112+
return IncomingPhoneNumber.creator(
118113
ACCOUNT_SID,
119114
local.getPhoneNumber()
120115
).create();

0 commit comments

Comments
 (0)