Search in sources :

Example 1 with CallCreator

use of com.twilio.rest.api.v2010.account.CallCreator in project twilio-java by twilio.

the class CallUpdaterExample method main.

@SuppressWarnings("checkstyle:javadocmethod")
public static void main(final String[] args) {
    Twilio.init("AC123", "AUTH TOKEN");
    try {
        CallCreator creator = Call.creator("AC123", new PhoneNumber("+14156085895"), new PhoneNumber("+14154888928"), new URI("http://twimlbin.com/cc413d9d"));
        Call call = creator.create();
        System.out.println(call.getSid());
        System.out.println(call.getStatus());
        System.out.println("press enter once call is accepted");
        try {
            System.in.read();
        } catch (final IOException e) {
            System.out.println("whoops");
        }
        CallUpdater updater = Call.updater("AC123", call.getSid()).setUrl(new URI("http://twimlbin.com/4397e62f"));
        Call updated = updater.update();
        System.out.println(updated.getSid());
        System.out.println(updated.getStatus());
    } catch (URISyntaxException | ApiException e) {
        System.err.println("womp womp");
        System.exit(1);
    }
}
Also used : CallUpdater(com.twilio.rest.api.v2010.account.CallUpdater) Call(com.twilio.rest.api.v2010.account.Call) PhoneNumber(com.twilio.type.PhoneNumber) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) CallCreator(com.twilio.rest.api.v2010.account.CallCreator) URI(java.net.URI) ApiException(com.twilio.exception.ApiException)

Example 2 with CallCreator

use of com.twilio.rest.api.v2010.account.CallCreator in project twilio-oai-generator by twilio.

the class APIIntegrationTest method testPost.

@Test
public void testPost() {
    Call call = new CallCreator(ACCOUNT_SID, "testString").create();
    assertEquals("Ahoy", call.getTestString());
    assertNotNull(call);
}
Also used : Call(com.twilio.rest.api.v2010.account.Call) CallCreator(com.twilio.rest.api.v2010.account.CallCreator) Test(org.junit.Test)

Example 3 with CallCreator

use of com.twilio.rest.api.v2010.account.CallCreator in project twilio-java by twilio.

the class Example method main.

/**
 * Example Twilio usage.
 *
 * @param args command line args
 * @throws TwiMLException if unable to generate TwiML
 */
public static void main(String[] args) throws TwiMLException, URISyntaxException {
    Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
    Iterable<Record> usage = Record.reader().read();
    for (Record record : usage) {
        System.out.println(record);
    }
    // Get a number
    IncomingPhoneNumber number = buyNumber();
    System.out.println(number.getPhoneNumber());
    // Send a text message
    Message message = Message.creator(ACCOUNT_SID, PHONE_NUMBER, number.getPhoneNumber(), "Hello world!").create();
    System.out.println(message.getSid());
    System.out.println(message.getBody());
    // Make a phone call
    Call call = new CallCreator(ACCOUNT_SID, PHONE_NUMBER, number.getPhoneNumber(), URI.create("https://twilio.com")).create();
    System.out.println(call.getSid());
    // Print all the messages
    Iterable<Message> messages = Message.reader().read();
    for (Message m : messages) {
        System.out.println(m.getSid());
        System.out.println(m.getBody());
    }
    // Get some calls
    Iterable<Call> calls = Call.reader().pageSize(2).read();
    for (Call c : calls) {
        System.out.println(c.getSid());
    }
    Trunk trunk = new TrunkCreator().setFriendlyName("shiny trunk").setSecure(false).create();
    System.out.println(trunk);
    // TwiML
    TwiML twiml = new VoiceResponse.Builder().say(new Say.Builder("Hello World!").build()).play(new Play.Builder().url(new URI("https://api.twilio.com/cowbell.mp3")).loop(5).build()).build();
    System.out.println(twiml.toXml());
}
Also used : Call(com.twilio.rest.api.v2010.account.Call) Trunk(com.twilio.rest.trunking.v1.Trunk) VoiceResponse(com.twilio.twiml.VoiceResponse) Message(com.twilio.rest.api.v2010.account.Message) TrunkCreator(com.twilio.rest.trunking.v1.TrunkCreator) URI(java.net.URI) Play(com.twilio.twiml.voice.Play) TwiML(com.twilio.twiml.TwiML) Record(com.twilio.rest.api.v2010.account.usage.Record) IncomingPhoneNumber(com.twilio.rest.api.v2010.account.IncomingPhoneNumber) CallCreator(com.twilio.rest.api.v2010.account.CallCreator)

Example 4 with CallCreator

use of com.twilio.rest.api.v2010.account.CallCreator in project twilio-java by twilio.

the class CallCreatorExample method main.

@SuppressWarnings("checkstyle:javadocmethod")
public static void main(final String[] args) {
    Twilio.init("AC123", "AUTH TOKEN");
    try {
        CallCreator creator = Call.creator("AC123", new PhoneNumber("+14156085895"), new PhoneNumber("+14154888928"), new URI("http://twimlbin.com/4397e62f"));
        Call call = creator.create();
        System.out.println(call.getSid());
        System.out.println(call.getStatus().toString());
    } catch (URISyntaxException | ApiException e) {
        System.err.println("womp womp");
        System.exit(1);
    }
}
Also used : Call(com.twilio.rest.api.v2010.account.Call) PhoneNumber(com.twilio.type.PhoneNumber) URISyntaxException(java.net.URISyntaxException) CallCreator(com.twilio.rest.api.v2010.account.CallCreator) URI(java.net.URI) ApiException(com.twilio.exception.ApiException)

Aggregations

Call (com.twilio.rest.api.v2010.account.Call)4 CallCreator (com.twilio.rest.api.v2010.account.CallCreator)4 URI (java.net.URI)3 ApiException (com.twilio.exception.ApiException)2 PhoneNumber (com.twilio.type.PhoneNumber)2 URISyntaxException (java.net.URISyntaxException)2 CallUpdater (com.twilio.rest.api.v2010.account.CallUpdater)1 IncomingPhoneNumber (com.twilio.rest.api.v2010.account.IncomingPhoneNumber)1 Message (com.twilio.rest.api.v2010.account.Message)1 Record (com.twilio.rest.api.v2010.account.usage.Record)1 Trunk (com.twilio.rest.trunking.v1.Trunk)1 TrunkCreator (com.twilio.rest.trunking.v1.TrunkCreator)1 TwiML (com.twilio.twiml.TwiML)1 VoiceResponse (com.twilio.twiml.VoiceResponse)1 Play (com.twilio.twiml.voice.Play)1 IOException (java.io.IOException)1 Test (org.junit.Test)1