Search in sources :

Example 1 with PinpointSmsVoiceClient

use of software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient in project aws-doc-sdk-examples by awsdocs.

the class SendNotifications method handleVoiceMessage.

public String handleVoiceMessage(String myDom) throws JDOMException, IOException {
    String mobileNum = "";
    List<String> listVal = new ArrayList<>();
    listVal.add("application/json");
    Map<String, List<String>> values = new HashMap<>();
    values.put("Content-Type", listVal);
    ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
    PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
    SAXBuilder builder = new SAXBuilder();
    Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
    org.jdom2.Element root = jdomDocument.getRootElement();
    // get a list of children elements.
    List<org.jdom2.Element> students = root.getChildren("Student");
    for (org.jdom2.Element element : students) {
        mobileNum = element.getChildText("Phone");
        sendVoiceMsg(client, mobileNum);
    }
    client.close();
    return mobileNum;
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) InputSource(org.xml.sax.InputSource) HashMap(java.util.HashMap) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) List(java.util.List) PinpointSmsVoiceClient(software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient)

Example 2 with PinpointSmsVoiceClient

use of software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient in project aws-doc-sdk-examples by awsdocs.

the class SendVoiceMessage method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage: " + "SendVoiceMessage <originationNumber> <destinationNumber> \n\n" + "Where:\n" + "  originationNumber - the phone number or short code that you specify has to be associated with your Amazon Pinpoint account. For best results, specify long codes in E.164 format (for example, +1-555-555-5654). " + "  destinationNumber - the recipient's phone number.  For best results, you should specify the phone number in E.164 format (for example, +1-555-555-5654). ";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String originationNumber = args[0];
    String destinationNumber = args[1];
    System.out.println("Sending a voice message");
    // Set the content type to application/json
    List<String> listVal = new ArrayList<>();
    listVal.add("application/json");
    Map<String, List<String>> values = new HashMap<>();
    values.put("Content-Type", listVal);
    ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
    PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
    sendVoiceMsg(client, originationNumber, destinationNumber);
    client.close();
}
Also used : HashMap(java.util.HashMap) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PinpointSmsVoiceClient(software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)2 PinpointSmsVoiceClient (software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient)2 StringReader (java.io.StringReader)1 Document (org.jdom2.Document)1 SAXBuilder (org.jdom2.input.SAXBuilder)1 InputSource (org.xml.sax.InputSource)1