com.elibom.client
Class ElibomRestClient

java.lang.Object
  extended by com.elibom.client.ElibomRestClient

public class ElibomRestClient
extends Object

The elibom.com REST API client.

Author:
Germán Escobar

Constructor Summary
ElibomRestClient(String username, String apiPassword)
          Initializes the client with the supplied username and apiPassword.
ElibomRestClient(String username, String apiPassword, String host)
          Mostly used for testing.
 
Method Summary
 Account getAccount()
          Query your account info.
 Delivery getDelivery(String deliveryId)
          Query the delivery with the specified deliveryId.
 Schedule getScheduledMessage(long id)
          Query the scheduled message with the specified id.
 List<Schedule> getScheduledMessages()
          Query the scheduled messages.
 User getUser(long id)
          Query a single account user.
 List<User> getUsers()
          Query your account users (those who have access to the account).
 long scheduleMessage(String to, String text, Date scheduleDate)
          Schedules an SMS message for the specified scheduleDate to one or more destinations and with the specified text.
 String sendMessage(String to, String text)
          Sends an SMS message to one or more destinations with the specified text.
 void unschedule(long id)
          Cancels the scheduled message with the specified id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElibomRestClient

public ElibomRestClient(String username,
                        String apiPassword)
Initializes the client with the supplied username and apiPassword.

Parameters:
username - the email you use to access your account at elibom.com.
apiPassword - your API password, which can be found in the settings section of your account.

ElibomRestClient

public ElibomRestClient(String username,
                        String apiPassword,
                        String host)
Mostly used for testing. Initializes the client with the supplied username, apiPassword and host. Mostly used for testing.

Parameters:
username - the email you use to access your account at elibom.com.
apiPassword - your API password, which you can find in the settings of your account.
host - the host to which the requests are going to be made.
Method Detail

sendMessage

public String sendMessage(String to,
                          String text)
                   throws HttpServerException,
                          RuntimeException
Sends an SMS message to one or more destinations with the specified text.

Parameters:
to - the destinations (separated by comma) to which you want to send the SMS message.
text - the text of the SMS message, max 160 characters.
Returns:
a String that you can use to query the delivery (using the getDelivery(String) method).
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

scheduleMessage

public long scheduleMessage(String to,
                            String text,
                            Date scheduleDate)
                     throws HttpServerException,
                            RuntimeException
Schedules an SMS message for the specified scheduleDate to one or more destinations and with the specified text.

Parameters:
to - the destinations (separated by comma) to which we are going to send the scheduled SMS message.
text - the text of the SMS message, max 160 characters.
scheduleDate - the date in which the message is going to be sent.
Returns:
the id of the scheduled message which you can query using the #getSchedule(long) method.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getDelivery

public Delivery getDelivery(String deliveryId)
                     throws HttpServerException,
                            RuntimeException
Query the delivery with the specified deliveryId.

Parameters:
deliveryId -
Returns:
a Delivery object with the info of the delivery and its messages.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getScheduledMessages

public List<Schedule> getScheduledMessages()
                                    throws HttpServerException,
                                           RuntimeException
Query the scheduled messages.

Returns:
a List of Schedule objects or an empty List if no schedule is found
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getScheduledMessage

public Schedule getScheduledMessage(long id)
                             throws HttpServerException,
                                    RuntimeException
Query the scheduled message with the specified id.

Parameters:
id - the id of the scheduled message to query.
Returns:
a Schedule object.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

unschedule

public void unschedule(long id)
                throws HttpServerException,
                       RuntimeException
Cancels the scheduled message with the specified id.

Parameters:
id - the id of the schedule to be canceled.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getUsers

public List<User> getUsers()
                    throws HttpServerException,
                           RuntimeException
Query your account users (those who have access to the account).

Returns:
a List of User objects.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getUser

public User getUser(long id)
             throws HttpServerException,
                    RuntimeException
Query a single account user.

Parameters:
id - the id of the account user to query.
Returns:
a User object.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.

getAccount

public Account getAccount()
                   throws HttpServerException,
                          RuntimeException
Query your account info.

Returns:
an Account object.
Throws:
HttpServerException - if the server responds with a HTTP status code other than 200 OK.
RuntimeException - wraps any other unexpected exception.


Copyright © 2013. All Rights Reserved.