v8 -> v9
Client Initialization
- v8
- v9
BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials("username", "password")
.voiceBasicAuthCredentials("username", "password")
.twoFactorAuthBasicAuthCredentials("username", "password")
.webRtcBasicAuthCredentials("username", "password")
.build();
ApiClient defaultClient = Configuration.getDefaultApiClient();
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");
Messaging
Create Message
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String to = "+15554443333";
ArrayList<String> toNumbers = new ArrayList<String>();
toNumbers.add(to);
String from = "+15553334444";
String applicationId = "3-a-b-d";
String text = "Hello from Java";
MessageRequest body = new MessageRequest();
body.setTo(toNumbers);
body.setFrom(from);
body.setText(text);
body.setApplicationId(applicationId);
ApiResponse<BandwidthMessage> createMessageResponse = messagingController.createMessage(ACCOUNT_ID, body);
System.out.println(createMessageResponse.getResult().getMessageId());
String accountId = "9900000";
String applicationId = "1234-qwer";
MessagesApi apiInstance = new MessagesApi(defaultClient);
messageRequest.applicationId(applicationId);
messageRequest.addToItem("+19195551234");
messageRequest.from("+19195554321");
messageRequest.text("Sample Text");
messageRequest.addMediaItem(URI.create("https://media.jpg"));
messageRequest.tag("Hello from Java");
messageRequest.priority(PriorityEnum.DEFAULT);
try {
Message result = apiInstance.createMessage(accountId, messageRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MessagesApi#createMessage");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
List Messages
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String bandwidthNumber = "+15554443333";
BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();
try {
CompletableFuture<ApiResponse<BandwidthMessagesList>> completableFuture = client.getMessagingClient().getAPIController().getMessagesAsync(ACCOUNT_ID, null, bandwidthNumber, null, null, null, null, null, null, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
String accountId = "9900000";
String messageId = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6";
String sourceTn = "%2B15554443333";
String destinationTn = "%2B15554443333";
MessageStatusEnum messageStatus = MessageStatusEnum.fromValue("RECEIVED");
ListMessageDirectionEnum messageDirection = ListMessageDirectionEnum.fromValue("INBOUND");
String carrierName = "Verizon";
MessageTypeEnum messageType = MessageTypeEnum.fromValue("sms");
Integer errorCode = 9902;
String fromDateTime = "2022-09-14T18:20:16.000Z";
String toDateTime = "2022-09-14T18:20:16.000Z";
String sort = "sourceTn:desc";
String pageToken = "gdEewhcJLQRB5";
Integer limit = 50;
try {
MessagesList result = apiInstance.listMessages(accountId, messageId, sourceTn, destinationTn, messageStatus, messageDirection, carrierName, messageType, errorCode, fromDateTime, toDateTime, sort, pageToken, limit);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MessagesApi#listMessages");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Media
List Media
- v8
- v9
public static final String ACCOUNT_ID = "12345";
try {
CompletableFuture<ApiResponse<List<Media>>> completableFuture = client.getMessagingClient().getAPIController().listMediaAsync(ACCOUNT_ID, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000";
String continuationToken = "1XEi2tsFtLo1JbtLwETnM1ZJ+PqAa8w6ENvC5QKvwyrCDYII663Gy5M4s40owR1tjkuWUif6qbWvFtQJR5/ipqbUnfAqL254LKNlPy6tATCzioKSuHuOqgzloDkSwRtX0LtcL2otHS69hK343m+SjdL+vlj71tT39";
try {
List<Media> result = apiInstance.listMedia(accountId, continuationToken);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#listMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Media
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String mediaId = "media-id-123";
try {
CompletableFuture<ApiResponse<InputStream>> completableFuture = client.getMessagingClient().getAPIController().getMediaAsync(ACCOUNT_ID, mediaId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000";
String mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png";
try {
File result = apiInstance.getMedia(accountId, mediaId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#getMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Upload Media
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String mediaId = "media-id-123";
FileWrapper fileWrapper = new FileWrapper(new File("/path/to/file"));
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getMessagingClient().getAPIController().uploadMediaAsync(ACCOUNT_ID, mediaId, fileWrapper, "content/type", "no-cache");
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000";
String mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png";
File body = new File("/path/to/file");
String contentType = "audio/wav";
String cacheControl = "no-cache";
try {
apiInstance.uploadMedia(accountId, mediaId, body, contentType, cacheControl);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#uploadMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Delete Media
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String mediaId = "media-id-123";
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getMessagingClient().getAPIController().deleteMediaAsync(ACCOUNT_ID, mediaId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000";
String mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png";
try {
apiInstance.deleteMedia(accountId, mediaId);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#deleteMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
BXML
Imports
- v8
- v9
import com.bandwidth.voice.bxml.verbs.*;
import com.bandwidth.voice.bxml.verbs.Record;
import org.openapitools.client.model.bxml.Bxml;
import org.openapitools.client.model.bxml.Forward;
import org.openapitools.client.model.bxml.Tag;
Bridge
- v8
- v9
Bridge bridge = Bridge.builder()
.callId("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d")
.bridgeCompleteUrl("https://bridge.url/nextBXMLForSecondCall")
.bridgeTargetCompleteUrl("https://bridge.url/nextBXMLForFirstCall")
.build();
Bridge bridge = new Bridge().builder()
.targetCallId("+19198675309")
.bridgeCompleteUrl("https://example.com")
.tag("test")
.build();
Conference
- v8
- v9
Conference conference = Conference.builder()
.name("my-conference-name")
.callIdsToCoach(ids)
.build();
Conference conference = new Conference().builder()
.name("conf1")
.mute(true)
.hold(false)
.callIdsToCoach("example-call-id")
.conferenceEventUrl("example.com/eventurl")
.conferenceEventMethod("POST")
.conferenceEventFallbackUrl("backupexample.com/eventurl")
.conferenceEventFallbackMethod("POST")
.username("user")
.password("pass")
.fallbackUsername("user")
.fallbackPassword("pass")
.tag("tag")
.callbackTimeout(5d)
.build();
Forward
- v8
- v9
Forward forward = Forward.builder()
.to("+10987654321")
.from("+11234567890")
.build();
Forward forward = new Forward().builder()
.to("+19195554321")
.from("19195554322")
.callTimeout(15d)
.diversionTreatment(DiversionTreatment.PROPAGATE)
.diversionReason(DiversionReason.AWAY)
.uui("93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt")
.build();
Gather
- v8
- v9
Gather gather = Gather.builder()
.gatherUrl("https://gather.url/nextBxml")
.terminatingDigits("#")
.firstDigitTimeout(10.0)
.audioProducer(speakSentence)
.build();
Gather gather = new Gather().builder()
.gatherUrl("test.com")
.gatherMethod("POST")
.gatherFallbackUrl("fallback-test.com")
.gatherFallbackMethod("GET")
.username("user")
.password("pass")
.fallbackUsername("user")
.fallbackPassword("pass")
.tag("tag")
.terminatingDigits("2")
.maxDigits(5)
.interDigitTimeout(1d)
.firstDigitTimeout(3d)
.repeatCount(2)
.children(List.of(playAudio, speakSentence))
.build();
Hangup
- v8
- v9
Hangup hangup = Hangup.builder().build();
Hangup hangup = new Hangup();
Pause
- v8
- v9
Pause pause = Pause.builder()
.duration(2.0)
.build();
Pause pause = new Pause(2d);
Pause Recording
- v8
- v9
PauseRecording pauseRecording = PauseRecording.builder().build();
PauseRecording pauseRecording = new PauseRecording();
Play Audio
- v8
- v9
PlayAudio playAudio1 = PlayAudio.builder()
.audioUri("https;//audio.url/audio1.wav")
.build();
PlayAudio playAudio = new PlayAudio().builder()
.audioUri("test.com")
.username("user")
.password("pass")
.build();
Record
- v8
- v9
Record record = Record.builder()
.recordCompleteUrl("https://myapp.com/nextBXML")
.recordingAvailableUrl("https://myapp.com/recordingAvailable")
.maxDuration(10)
.build();
Record record = new Record().builder()
.maxDuration(10)
.build();
Redirect
- v8
- v9
Redirect redirect = Redirect.builder()
.redirectUrl("https://flow.url/newFlow")
.build();
Redirect redirect = new Redirect().builder()
.redirectUrl("https://example.com/redirect")
.redirectFallbackUrl("fallback-url.com")
.redirectMethod("POST")
.build();
Resume Recording
- v8
- v9
ResumeRecording resumeRecording = ResumeRecording.builder().build();
ResumeRecording resumeRecording = new ResumeRecording();
Ring
- v8
- v9
Ring ring = Ring.builder()
.duration(10.0)
.answerCall(false)
.build();
Ring ring = new Ring(30d, false);
Send DTMF
- v8
- v9
SendDtmf sendDtmf = SendDtmf.builder()
.digits("12w34")
.build();
SendDtmf sendDtmf = new SendDtmf("12w34", 3,5);
Speak Sentence
- v8
- v9
SpeakSentence speakSentence = SpeakSentence.builder()
.text("This is a test.")
.voice("julie")
.build();
SpeakSentence speakSentence = new SpeakSentence().builder()
.innerTags(List.of(sentence))
.locale(TtsLocale.EN_UK)
.gender(TtsGender.FEMALE)
.build();
Start Gather
- v8
- v9
StartGather startGather = StartGather.builder()
.dtmfUrl("https://startgather.url/callback")
.build();
StartGather startGather = new StartGather().builder()
.dtmfUrl("https://example.com/startgather")
.dtmfMethod("POST")
.username("user")
.password("pass")
.tag("tag")
.build();
Start Recording
- v8
- v9
StartRecording startRecording = StartRecording.builder()
.recordingAvailableUrl("https://myapp.com/noBXML")
.build();
StartRecording startRecording = new StartRecording().builder()
.recordingAvailableUrl("https://example.com")
.recordingAvailableMethod("POST")
.transcribe(true)
.transcriptionAvailableUrl("transcription-example.com")
.recordingAvailableMethod("POST")
.username("user")
.password("pass")
.tag("tag")
.fileFormat("wav")
.multiChannel(true)
.build();
Start Stream
- v8
- v9
StreamParam streamParam = StreamParam.builder()
.name("internal_id")
.value("call_ABC")
.build();
StartStream startStream = StartStream.builder()
.name("live_audience")
.tracks("both")
.destination("wss://live-studio-audience.myapp.example.com")
.streamEventUrl("https://myapp.example.com/noBXML")
.streamParams(streamParam)
.build();
StreamParam streamParam1 = new StreamParam().builder()
.name("name1")
.value("value1")
.build();
StreamParam streamParam2 = new StreamParam().builder()
.name("name2")
.value("value2")
.build();
StartStream startStream = new StartStream().builder()
.name("stream1")
.tracks(CallDirectionEnum.INBOUND)
.destination("testurl.com")
.streamEventUrl("eventurl.com")
.streamEventMethod("POST")
.username("user")
.password("pass")
.streamParams(List.of(streamParam1, streamParam2))
.build();
Stop Gather
- v8
- v9
StopGather stopGather = StopGather.builder().build();
StopGather stopGather = new StopGather();
Stop Recording
- v8
- v9
StopRecording stopRecording = StopRecording.builder().build();
StopRecording stopRecording = new StopRecording();
Stop Stream
- v8
- v9
StopStream stopStream = StopStream.builder()
.name("live_audience")
.build();
StopStream stopStream = new StopStream("live_audience");
Tag
- v8
- v9
Tag tag = Tag.builder()
.value("audio playing")
.build();
Tag tag1 = new Tag("audio playing");
Transfer
- v8
- v9
PhoneNumber phoneNumber = PhoneNumber.builder()
.phoneNumber("+11234567892")
.build();
Transfer transfer = Transfer.builder()
.transferCallerId("+11234567891")
.phoneNumbers(phoneNumber)
.build();
PhoneNumber phoneNumber = new PhoneNumber().builder()
.number("+19195551234")
.transferAnswerUrl("https://example.com/webhooks/transfer_answer")
.tag("test")
.transferAnswerMethod("POST")
.build();
Transfer transfer = new Transfer().builder()
.callTimeout(15d)
.destinations(List.of(phoneNumber))
.transferCallerId("+19195554321")
.tag("test")
.build();
Calls
Create Call
- v8
- v9
String to = "+15553334444";
String from = "+15554443333";
String baseUrl = "https://sample.com";
String answerUrl = baseUrl.concat("/callbacks/answer");
CreateCallRequest request = new CreateCallRequest();
request.setApplicationId(voiceApplicationId);
request.setTo(to);
request.setFrom(from);
request.setAnswerUrl(answerUrl);
try {
CompletableFuture<ApiResponse<CreateCallResponse>> completableFuture = client.getVoiceClient().getAPIController().createCallAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
CallsApi apiInstance = new CallsApi(defaultClient);
String accountId = "9900000";
CreateCall createCall = new CreateCall();
try {
CreateCallResponse result = apiInstance.createCall(accountId, createCall);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#createCall");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Call Information
- v8
- v9
try {
CompletableFuture<ApiResponse<CallState>> completableFuture = client.getVoiceClient().getAPIController().getCallAsync(ACCOUNT_ID, callId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
CallsApi apiInstance = new CallsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
CallState result = apiInstance.getCallState(accountId, callId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#getCallState");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Update Call
- v8
- v9
ModifyCallRequest request = new ModifyCallRequest();
request.setState(StateEnum.COMPLETED);
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().modifyCallAsync(ACCOUNT_ID, callId, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
CallsApi apiInstance = new CallsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
UpdateCall updateCall = new UpdateCall();
try {
apiInstance.updateCall(accountId, callId, updateCall);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#updateCall");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Replace Call BXML
- v8
- v9
// Not Possible with V8.
SpeakSentence speakSentence = new SpeakSentence().builder()
.innerTags("Test sentence.")
.locale(TtsLocale.EN_UK)
.gender(TtsGender.FEMALE)
.build();
CallsApi apiInstance = new CallsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String body = new Bxml().with(speakSentence).toBxml(jaxbContext);
try {
apiInstance.updateCallBxml(accountId, callId, body);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#updateCallBxml");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Conferences
List Conferences
- v8
- v9
public static final String ACCOUNT_ID = "12345";
try {
CompletableFuture<ApiResponse<List<ConferenceState>>> completableFuture = client.getVoiceClient().getAPIController().getConferencesAsync(ACCOUNT_ID, null, null, null, null, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String name = "my-custom-name";
String minCreatedTime = "2022-06-21T19:13:21Z";
String maxCreatedTime = "2022-06-21T19:13:21Z";
Integer pageSize = 1000;
String pageToken = "pageToken_example";
try {
List<Conference> result = apiInstance.listConferences(accountId, name, minCreatedTime, maxCreatedTime, pageSize, pageToken);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#listConferences");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Conference Information
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
try {
CompletableFuture<ApiResponse<ConferenceState>> completableFuture = client.getVoiceClient().getAPIController().getConferenceAsync(ACCOUNT_ID, conferenceId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
try {
Conference result = apiInstance.getConference(accountId, conferenceId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#getConference");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Update Conference
- v8
- v9
public static final String ACCOUNT_ID = "12345";
ModifyConferenceRequest request = new ModifyConferenceRequest();
request.setStatus(StatusEnum.COMPLETED);
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().modifyConferenceAsync(ACCOUNT_ID, conferenceId, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
UpdateConference updateConference = new UpdateConference();
try {
apiInstance.updateConference(accountId, conferenceId, updateConference);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#updateConference");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Update Conference BXML
- v8
- v9
// Not Possible with V8.
SpeakSentence speakSentence = new SpeakSentence().builder()
.innerTags("Test sentence.")
.locale(TtsLocale.EN_UK)
.gender(TtsGender.FEMALE)
.build();
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
String body = new Bxml().with(speakSentence).toBxml(jaxbContext);
try {
apiInstance.updateConferenceBxml(accountId, conferenceId, body);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#updateConferenceBxml");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Conference Member
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
String memberId = "c-95ac8d8d-b81437f5-4586-4d5b-9b46-29f8b3fe0aaf";
try {
CompletableFuture<ApiResponse<ConferenceMemberState>> completableFuture = client.getVoiceClient().getAPIController().getConferenceMemberAsync(ACCOUNT_ID, conferenceId, memberId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
String memberId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
ConferenceMember result = apiInstance.getConferenceMember(accountId, conferenceId, memberId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#getConferenceMember");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Update Conference Member
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
String memberId = "c-95ac8d8d-b81437f5-4586-4d5b-9b46-29f8b3fe0aaf";
ConferenceMemberState conferenceMemberState = new ConferenceMemberState();
conferenceMemberState.setMute(true);
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().modifyConferenceMemberAsync(ACCOUNT_ID, conferenceId, callId, conferenceMemberState);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
String memberId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
UpdateConferenceMember updateConferenceMember = new UpdateConferenceMember();
try {
apiInstance.updateConferenceMember(accountId, conferenceId, memberId, updateConferenceMember);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#updateConferenceMember");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
List Conference Recordings
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
try {
CompletableFuture<ApiResponse<List<ConferenceRecordingMetadata>>> completableFuture = client.getVoiceClient().getAPIController().getConferenceRecordingsAsync(ACCOUNT_ID, conferenceId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
try {
List<ConferenceRecordingMetadata> result = apiInstance.listConferenceRecordings(accountId, conferenceId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#listConferenceRecordings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Conference Recording Information
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<CallRecordingMetadata>> completableFuture = client.getVoiceClient().getAPIController().getConferenceRecordingAsync(ACCOUNT_ID, conferenceId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
ConferenceRecordingMetadata result = apiInstance.getConferenceRecording(accountId, conferenceId, recordingId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#getConferenceRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Download Conference Recording
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String conferenceId = "conf-95ac8d8d-28e06798-2afe-434c-b0f4-666a79cd47f8";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<DynamicResponse>> completableFuture = client.getVoiceClient().getAPIController().getDownloadConferenceRecordingAsync(ACCOUNT_ID, conferenceId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
String accountId = "9900000";
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
File result = apiInstance.downloadConferenceRecording(accountId, conferenceId, recordingId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConferencesApi#downloadConferenceRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Recordings
List Account Call Recordings
- v8
- v9
public static final String ACCOUNT_ID = "12345";
try {
CompletableFuture<ApiResponse<List<CallRecordingMetadata>>> completableFuture = client.getVoiceClient().getAPIController().getQueryCallRecordingsAsync(ACCOUNT_ID, null, null, null, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String to = "%2b19195551234";
String from = "%2b19195554321";
String minStartTime = "2022-06-21T19:13:21Z";
String maxStartTime = "2022-06-21T19:13:21Z";
try {
List<CallRecordingMetadata> result = apiInstance.listAccountCallRecordings(accountId, to, from, minStartTime, maxStartTime);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#listAccountCallRecordings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Update Recording
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
ModifyCallRecordingRequest recordingRequest = new ModifyCallRecordingRequest();
recordingRequest.setState(State1Enum.PAUSED);
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().modifyCallRecordingStateAsync(ACCOUNT_ID, callId, recordingRequest);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
UpdateCallRecording updateCallRecording = new UpdateCallRecording();
try {
apiInstance.updateCallRecordingState(accountId, callId, updateCallRecording);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#updateCallRecordingState");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
List Call Recordings
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
try {
CompletableFuture<ApiResponse<List<CallRecordingMetadata>>> completableFuture = client.getVoiceClient().getAPIController().getCallRecordingsAsync(ACCOUNT_ID, callId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
List<CallRecordingMetadata> result = apiInstance.listCallRecordings(accountId, callId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#listCallRecordings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Call Recording
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<CallRecordingMetadata>> completableFuture = client.getVoiceClient().getAPIController().getCallRecordingAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
CallRecordingMetadata result = apiInstance.getCallRecording(accountId, callId, recordingId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#getCallRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Delete Recording
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().deleteRecordingAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
apiInstance.deleteRecording(accountId, callId, recordingId);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#deleteRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Download Recording
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<DynamicResponse>> completableFuture = client.getVoiceClient().getAPIController().getDownloadCallRecordingAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
File result = apiInstance.downloadCallRecording(accountId, callId, recordingId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#downloadCallRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Delete Recording Media
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().deleteRecordingMediaAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
apiInstance.deleteRecordingMedia(accountId, callId, recordingId);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#deleteRecordingMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Transcription
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<TranscriptionResponse>> completableFuture = client.getVoiceClient().getAPIController().getCallTranscriptionAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
TranscriptionList result = apiInstance.getCallTranscription(accountId, callId, recordingId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#getCallTranscription");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Create Transcription Request
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
TranscribeRecordingRequest request = new TranscribeRecordingRequest();
request.setCallbackUrl("https://sample.com/callbacks/transcribe");
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().createTranscribeCallRecordingAsync(ACCOUNT_ID, callId, recordingId, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
TranscribeRecording transcribeRecording = new TranscribeRecording();
try {
apiInstance.transcribeCallRecording(accountId, callId, recordingId, transcribeRecording);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#transcribeCallRecording");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Delete Transcription
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String callId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d";
String recordingId = "r-d68201ef-d53e-4c6d-a743-1c1283909d41";
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getVoiceClient().getAPIController().deleteCallTranscriptionAsync(ACCOUNT_ID, callId, recordingId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
RecordingsApi apiInstance = new RecordingsApi(defaultClient);
String accountId = "9900000";
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
String recordingId = "r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85";
try {
apiInstance.deleteCallTranscription(accountId, callId, recordingId);
} catch (ApiException e) {
System.err.println("Exception when calling RecordingsApi#deleteCallTranscription");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Telephone Number Lookup
Create Lookup
- v8
- v9
public static final String ACCOUNT_ID = "12345";
List<String> numbers = new ArrayList<>();
numbers.add("+15553334444");
OrderRequest request = new OrderRequest(numbers);
try {
CompletableFuture<ApiResponse<OrderResponse>> completableFuture = client.getPhoneNumberLookupClient().getAPIController().createLookupRequestAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
PhoneNumberLookupApi apiInstance = new PhoneNumberLookupApi(defaultClient);
String accountId = "9900000";
LookupRequest lookupRequest = new LookupRequest();
try {
CreateLookupResponse result = apiInstance.createLookup(accountId, lookupRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PhoneNumberLookupApi#createLookup");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Get Lookup Request Status
- v8
- v9
public static final String ACCOUNT_ID = "12345";
String requestId = "8a358296-e188-4a3a-b974-8e4d12001dd8";
try {
CompletableFuture<ApiResponse<OrderStatus>> completableFuture = client.getPhoneNumberLookupClient().getAPIController().getLookupRequestStatusAsync(ACCOUNT_ID, requestId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
PhoneNumberLookupApi apiInstance = new PhoneNumberLookupApi(defaultClient);
String accountId = "9900000";
String requestId = "004223a0-8b17-41b1-bf81-20732adf5590";
try {
LookupStatus result = apiInstance.getLookupStatus(accountId, requestId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PhoneNumberLookupApi#getLookupStatus");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Multi-Factor Authentication
Voice MFA Code
- v8
- v9
public static final String ACCOUNT_ID = "12345";
public static final String APPLICATION_ID = "1234-qwer";
String to = "+15553334444";
String from = "+15554443333";
String scope = "sample";
int digits = 6;
String message = "Your temporary {NAME} {SCOPE} code is {CODE}";
TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema();
request.setApplicationId(APPLICATION_ID);
request.setTo(to);
request.setFrom(from);
request.setScope(scope);
request.setDigits(digits);
request.setMessage(message);
try {
CompletableFuture<ApiResponse<TwoFactorVoiceResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVoiceTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MfaApi apiInstance = new MfaApi(defaultClient);
String accountId = "9900000";
String applicationId = "1234-qwer";
CodeRequest request = new CodeRequest();
request.setTo("+19195551234");
request.setFrom("+19195554321");
request.setApplicationId(applicationId);
request.setScope("scope");
request.setMessage("Your temporary {NAME} {SCOPE} code is {CODE}");
request.setDigits(6);
try {
VoiceCodeResponse result = apiInstance.generateVoiceCode(accountId, request);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#generateVoiceCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Messaging MFA Code
- v8
- v9
public static final String ACCOUNT_ID = "12345";
public static final String APPLICATION_ID = "1234-qwer";
String to = "+15553334444";
String from = "+15554443333";
String scope = "sample";
int digits = 6;
String message = "Your temporary {NAME} {SCOPE} code is {CODE}";
TwoFactorCodeRequestSchema request = new TwoFactorCodeRequestSchema();
request.setApplicationId(APPLICATION_ID);
request.setTo(to);
request.setFrom(from);
request.setScope(scope);
request.setDigits(digits);
request.setMessage(message);
try {
CompletableFuture<ApiResponse<TwoFactorMessagingResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createMessagingTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
MfaApi apiInstance = new MfaApi(defaultClient);
String accountId = "9900000";
String applicationId = "1234-qwer";
CodeRequest request = new CodeRequest();
request.setTo("+19195551234");
request.setFrom("+19195554321");
request.setApplicationId(applicationId);
request.setScope("scope");
request.setMessage("Your temporary {NAME} {SCOPE} code is {CODE}");
request.setDigits(6);
try {
MessagingCodeResponse result = apiInstance.generateMessagingCode(accountId, codeRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#generateMessagingCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
Verify MFA Code
- v8
- v9
public static final String ACCOUNT_ID = "12345";
public static final String APPLICATION_ID = "1234-qwer";
String to = "+15553334444";
String scope = "sample";
String code = "159193";
int expirationTimeInMinutes = 3;
TwoFactorVerifyRequestSchema request = new TwoFactorVerifyRequestSchema();
request.setApplicationId(APPLICATION_ID);
request.setTo(to);
request.setScope(scope);
request.setCode(code);
request.setExpirationTimeInMinutes(expirationTimeInMinutes);
try {
CompletableFuture<ApiResponse<TwoFactorVerifyCodeResponse>> completableFuture = client.getMultiFactorAuthClient().getMFAController().createVerifyTwoFactorAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
}
BigDecimal expirationTime = new BigDecimal(3);
Long minTn = 1111111111L;
Long maxTn = 9999999999L;
VerifyCodeRequest request = new VerifyCodeRequest();
request.setTo("+19195551234");
request.setScope("2FA");
request.setExpirationTimeInMinutes(expirationTime);
request.setCode("123456");
try {
VerifyCodeResponse result = apiInstance.verifyCode(accountId, request);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MfaApi#verifyCode");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}