Class SmsClient
- java.lang.Object
-
- com.nexmo.client.sms.SmsClient
-
public class SmsClient extends java.lang.Object
A client for talking to the Nexmo Voice API. The standard way to obtain an instance of this class is to useNexmoClient.getSmsClient().
-
-
Constructor Summary
Constructors Constructor Description SmsClient(HttpWrapper httpWrapper)Create a new SmsClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SmsSingleSearchResponsegetSms(java.lang.String id)Search for a single SMS by id.SearchSmsResponsesearchMessages(SearchSmsRequest request)Search for completed SMS transactions.SearchSmsResponsesearchMessages(java.lang.String id, java.lang.String... ids)Search for completed SMS transactions by IDSearchSmsResponsesearchMessages(java.util.Date date, java.lang.String to)Search for completed SMS transactions by date and recipient MSISDN.SearchRejectedMessagesResponsesearchRejectedMessages(SearchRejectedMessagesRequest request)Search for rejected SMS transactions using aSearchRejectedMessagesRequest.SearchRejectedMessagesResponsesearchRejectedMessages(java.util.Date date, java.lang.String to)Search for rejected SMS transactions by date and recipient MSISDN.SmsSubmissionResponsesubmitMessage(Message message)Send an SMS message.
-
-
-
Constructor Detail
-
SmsClient
public SmsClient(HttpWrapper httpWrapper)
Create a new SmsClient.
-
-
Method Detail
-
submitMessage
public SmsSubmissionResponse submitMessage(Message message) throws NexmoResponseParseException, NexmoClientException
Send an SMS message.This uses the supplied object to construct a request and post it to the Nexmo API.
This method will respond with an SmsSubmissionResponse object. Depending on the nature and length of the submitted message, Nexmo may automatically split the message into multiple sms messages in order to deliver to the handset. For example, a long text sms of greater than 160 chars will need to be split into multiple 'concatenated' sms messages. The Nexmo service will handle this automatically for you.
The messages are stored as a Collection of SmsSubmissionResponseMessage objects on the SmsSubmissionResponse object. Each message can potentially have a different status result, and each message will have a different message id. Delivery notifications will be generated for each sms message within this set and will be posted to your application containing the appropriate message id.- Parameters:
message- The message request object that describes the type of message and the contents to be submitted.- Returns:
- SmsSubmissionResponse an object containing a collection of SmsSubmissionResponseMessage objects for each actual sms that was required to submit the message.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
searchMessages
public SearchSmsResponse searchMessages(SearchSmsRequest request) throws NexmoResponseParseException, NexmoClientException
Search for completed SMS transactions.You should probably use the helper methods
searchMessages(String, String...)orsearchMessages(String, String...)instead.- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
searchMessages
public SearchSmsResponse searchMessages(java.lang.String id, java.lang.String... ids) throws NexmoResponseParseException, NexmoClientException
Search for completed SMS transactions by ID- Parameters:
id- the first ID to look upids- optional extra IDs to look up- Returns:
- SMS data matching the provided criteria.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
searchMessages
public SearchSmsResponse searchMessages(java.util.Date date, java.lang.String to) throws NexmoResponseParseException, NexmoClientException
Search for completed SMS transactions by date and recipient MSISDN.- Parameters:
date- the date of the SMS message to be looked upto- the MSISDN number of the SMS recipient- Returns:
- SMS data matching the provided criteria
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
searchRejectedMessages
public SearchRejectedMessagesResponse searchRejectedMessages(SearchRejectedMessagesRequest request) throws NexmoResponseParseException, NexmoClientException
Search for rejected SMS transactions using aSearchRejectedMessagesRequest.You should probably use
searchRejectedMessages(Date, String)instead.- Returns:
- rejection data matching the provided criteria
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
searchRejectedMessages
public SearchRejectedMessagesResponse searchRejectedMessages(java.util.Date date, java.lang.String to) throws NexmoResponseParseException, NexmoClientException
Search for rejected SMS transactions by date and recipient MSISDN.- Parameters:
date- the date of the rejected SMS message to be looked upto- the MSISDN number of the SMS recipient- Returns:
- rejection data matching the provided criteria
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
getSms
public SmsSingleSearchResponse getSms(java.lang.String id) throws NexmoResponseParseException, NexmoClientException
Search for a single SMS by id.- Parameters:
id- The message id to search for.- Returns:
- SmsSingleSearchResponse object containing the details of the SMS.
- Throws:
NexmoClientException- if there was a problem with the Nexmo request or response objects.NexmoResponseParseException- if the response from the API could not be parsed.
-
-