package com.nexmo.quickstart.voice;

import com.nexmo.client.NexmoClient;
import com.nexmo.client.auth.AuthMethod;
import com.nexmo.client.auth.JWTAuthMethod;
import com.nexmo.client.voice.Call;

import java.nio.file.FileSystems;

import static com.nexmo.quickstart.Util.configureLogging;
import static com.nexmo.quickstart.Util.envVar;

public class OutboundTextToSpeech {
    public static void main(String[] args) throws Exception {
        configureLogging();

        String NEXMO_APPLICATION_ID = envVar("APPLICATION_ID");
        String NEXMO_APPLICATION_PRIVATE_KEY = envVar("PRIVATE_KEY");
        String NEXMO_NUMBER = envVar("NEXMO_NUMBER");
        String TO_NUMBER = envVar("TO_NUMBER");
        String ANSWER_URL = "https://developer.nexmo.com/ncco/tts.json";

        AuthMethod auth = new JWTAuthMethod(
                NEXMO_APPLICATION_ID,
                FileSystems.getDefault().getPath(NEXMO_APPLICATION_PRIVATE_KEY)
        );
        NexmoClient client = new NexmoClient(auth);
        client.getVoiceClient().createCall(
                new Call(TO_NUMBER, NEXMO_NUMBER, ANSWER_URL)
        );
    }
}

@@ -588,32 +588,33 @@
 VATE_KEY%22);%0A
+%0A
         
 String NEXMO
@@ -605,201 +605,61 @@
     
-String NEXMO_NUMBER = envVar(%22NEXMO_NUMBER%22);%0A        String TO_NUMBER = envVar(%22TO_NUMBER%22);%0A        String ANSWER_URL = %22https://developer.nexmo.com/ncco/tts.json%22;%0A%0A        AuthMethod auth =
+NexmoClient client = new NexmoClient(%0A               
  new
@@ -674,16 +674,24 @@
 Method(%0A
+        
         
@@ -736,16 +736,24 @@
         
+        
 FileSyst
@@ -808,16 +808,34 @@
 TE_KEY)%0A
+                )%0A
         
@@ -837,24 +837,25 @@
      );%0A
+%0A
         
 NexmoCli
@@ -850,51 +850,175 @@
     
-NexmoClient client = new NexmoClient(auth);
+String NEXMO_NUMBER = envVar(%22NEXMO_NUMBER%22);%0A        String TO_NUMBER = envVar(%22TO_NUMBER%22);%0A        String ANSWER_URL = %22https://developer.nexmo.com/ncco/tts.json%22;%0A
 %0A   

Clean up for building blocks.