public class VoiceClient extends AbstractClient
NexmoClient.getVoiceClient()
.Modifier and Type | Field and Description |
---|---|
protected CallsEndpoint |
calls |
protected DtmfEndpoint |
dtmf |
protected StreamsEndpoint |
streams |
protected TalkEndpoint |
talk |
httpWrapper
Constructor and Description |
---|
VoiceClient(HttpWrapper httpWrapper)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
CallEvent |
createCall(Call callRequest)
Begin a call to a phone number.
|
CallInfo |
getCallDetails(java.lang.String uuid)
Look up the status of a single call initiated by
createCall(Call) . |
CallInfoPage |
listCalls()
Obtain the first page of CallInfo objects, representing the most recent calls initiated by
createCall(Call) . |
CallInfoPage |
listCalls(CallsFilter filter)
Obtain the first page of CallInfo objects matching the query described by filter, representing the most
recent calls initiated by
createCall(Call) . |
ModifyCallResponse |
modifyCall(java.lang.String uuid,
java.lang.String action)
Hang up a call.
|
DtmfResponse |
sendDtmf(java.lang.String uuid,
java.lang.String digits)
Send DTMF codes to an ongoing call.
|
StreamResponse |
startStream(java.lang.String uuid,
java.lang.String streamUrl)
Stream audio to an ongoing call.
|
StreamResponse |
startStream(java.lang.String uuid,
java.lang.String streamUrl,
int loop)
Stream audio to an ongoing call.
|
TalkResponse |
startTalk(java.lang.String uuid,
java.lang.String text)
Send a synthesized speech message to an ongoing call.
|
TalkResponse |
startTalk(java.lang.String uuid,
java.lang.String text,
int loop)
Send a synthesized speech message to an ongoing call.
|
TalkResponse |
startTalk(java.lang.String uuid,
java.lang.String text,
VoiceName voiceName)
Send a synthesized speech message to an ongoing call.
|
TalkResponse |
startTalk(java.lang.String uuid,
java.lang.String text,
VoiceName voiceName,
int loop)
Send a synthesized speech message to an ongoing call.
|
StreamResponse |
stopStream(java.lang.String uuid)
Stop the audio being streamed into a call.
|
TalkResponse |
stopTalk(java.lang.String uuid)
Stop the message being spoken into a call.
|
protected final CallsEndpoint calls
protected final StreamsEndpoint streams
protected final TalkEndpoint talk
protected final DtmfEndpoint dtmf
public VoiceClient(HttpWrapper httpWrapper)
httpWrapper
- (required) shared HTTP wrapper object used for making REST calls.public CallEvent createCall(Call callRequest) throws java.io.IOException, NexmoClientException
callRequest
- Describing the call to be made.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public CallInfoPage listCalls() throws java.io.IOException, NexmoClientException
createCall(Call)
.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public CallInfoPage listCalls(CallsFilter filter) throws java.io.IOException, NexmoClientException
createCall(Call)
.filter
- (optional) A filter describing which calls to be listed.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public CallInfo getCallDetails(java.lang.String uuid) throws java.io.IOException, NexmoClientException
createCall(Call)
.uuid
- (required) The UUID of the call, obtained from the object returned by createCall(Call)
.
This value can be obtained with CallEvent.getUuid()
java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public DtmfResponse sendDtmf(java.lang.String uuid, java.lang.String digits) throws java.io.IOException, NexmoClientException
uuid
- (required) The UUID of the call, obtained from the object returned by createCall(Call)
.
This value can be obtained with CallEvent.getUuid()
digits
- (required) A string specifying the digits to be sent to the call. Valid characters are the digits
1-9, #, *, with the special character p indicating a short
pause between tones.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public ModifyCallResponse modifyCall(java.lang.String uuid, java.lang.String action) throws java.io.IOException, NexmoClientException
In future, further operations will be possible. At the moment, the only valid value for action is hangup.
uuid
- (required) The UUID of the call, obtained from the object returned by createCall(Call)
.
This value can be obtained with CallEvent.getUuid()
action
- The word "hangup"java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public StreamResponse startStream(java.lang.String uuid, java.lang.String streamUrl, int loop) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
streamUrl
- A URL of an audio file in MP3 or 16-bit WAV format, to be streamed to the call.loop
- The number of times to repeat the audio. The default value is 1, or you can use
0 to indicate that the audio should be repeated indefinitely.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public StreamResponse startStream(java.lang.String uuid, java.lang.String streamUrl) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
streamUrl
- A URL of an audio file in MP3 or 16-bit WAV format, to be streamed to the call.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public StreamResponse stopStream(java.lang.String uuid) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public TalkResponse startTalk(java.lang.String uuid, java.lang.String text) throws java.io.IOException, NexmoClientException
The message will only play once, spoken with the default voice of Kimberly.
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
text
- The message to be spoken to the call participants.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public TalkResponse startTalk(java.lang.String uuid, java.lang.String text, VoiceName voiceName) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
text
- The message to be spoken to the call participants.voiceName
- The voice to be used to speak the message.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public TalkResponse startTalk(java.lang.String uuid, java.lang.String text, int loop) throws java.io.IOException, NexmoClientException
The message will be spoken with the default voice of Kimberly.
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
text
- The message to be spoken to the call participants.loop
- The number of times to repeat the message. The default value is 1, or you can use
0 to indicate that the message should be repeated indefinitely.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public TalkResponse startTalk(java.lang.String uuid, java.lang.String text, VoiceName voiceName, int loop) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
text
- The message to be spoken to the call participants.voiceName
- The voice to be used to speak the message.loop
- The number of times to repeat the message. The default value is 1, or you can use
0 to indicate that the message should be repeated indefinitely.java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.public TalkResponse stopTalk(java.lang.String uuid) throws java.io.IOException, NexmoClientException
uuid
- The UUID of the call, obtained from the object returned by createCall(Call)
. This value can
be obtained with CallEvent.getUuid()
java.io.IOException
- if a network error occurred contacting the Nexmo Voice API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.