package com.bluevia.android.messagery.mt.sms.client;
import java.io.IOException;
import java.util.ArrayList;
import com.bluevia.android.commons.data.UserId;
import com.bluevia.android.commons.data.UserId.Type;
import com.bluevia.android.commons.exception.BlueviaException;
import com.bluevia.android.messagery.mt.sms.data.SmsMessageReq;
/**
*
* Client interface for the REST binding of the Bluevia SMS MT Service.
*
* @author Telefonica R&D
*
*/
public class BVMtSms extends BVMtSmsClient {
protected static final String FEED_SMS_BASE_URI = "/REST/SMS";
/**
* Constructor
*
* @param mode
* @param consumerKey
* @param consumerSecret
* @param token
* @param tokenSecret
* @throws BlueviaException
*/
public BVMtSms(Mode mode, String consumerKey, String consumerSecret,
String token, String tokenSecret) throws BlueviaException{
initUntrusted(mode, consumerKey, consumerSecret, token, tokenSecret);
init();
mBaseUri += buildUri(mMode, FEED_SMS_BASE_URI) + FEED_OUTBOUND_REQUESTS;
}
/**
* Allows to send and SMS to the gSDP. It returns a String containing the SMSID of the sent SMS,
* in order to ask later for the status of the message.
* The max length of the message must be less than 160 characters.
* @param destination the address of the recipient of the message
* @param text the text of the message
*
* @return the sent SMS ID
* @throws BlueviaException
* @throws IOException
*/
public String send(String destination, String text) throws BlueviaException, IOException {
return send(destination, text, null, null);
}
/**
* Allows to send and SMS to the gSDP. Sent SMS notifications will be received in the endpoint
* The SMSID of the sent SMS is returned in order to ask later for the status of the message as well.
* The max length of the message must be less than 160 characters.
* @param destination the address of the recipient of the message
* @param text the text of the message
* @param endpoint the endpoint to receive notifications of sent SMSs
* @param correlator the correlator
*
* @return the sent SMS ID
* @throws BlueviaException
* @throws IOException
*/
public String send(String destination, String text, String endpoint, String correlator) throws BlueviaException, IOException {
return send(new SmsMessageReq(text, new UserId(Type.PHONE_NUMBER, destination), endpoint, correlator));
}
/**
* Allows to send and SMS to the gSDP. It returns a String containing the SMSID of the sent SMS,
* in order to ask later for the status of the message.
* The max length of the message must be less than 160 characters.
* @param destination the addresses of the recipients of the message
* @param text the text of the message
*
* @return the sent SMS ID
* @throws BlueviaException
* @throws IOException
*/
public String send(ArrayList<String> destination, String text) throws BlueviaException, IOException {
return send(destination, text, null, null);
}
/**
*
* Allows to send and SMS to the gSDP. Sent SMS notifications will be received in the endpoint.
* The SMSID of the sent SMS is returned in order to ask later for the status of the message as well.
* The max length of the message must be less than 160 characters.
* @param destination the addresses of the recipients of the message
* @param text the text of the message
* @param endpoint the endpoint to receive notifications of sent SMSs
* @param correlator the correlator
*
* @return the sent SMS ID
* @throws BlueviaException
* @throws IOException
*/
public String send(ArrayList<String> destination, String text, String endpoint, String correlator) throws BlueviaException, IOException {
ArrayList<UserId> addressList = buildUserIdList(destination);
return send(new SmsMessageReq(text, addressList, endpoint, correlator));
}
/**
* Allows to send and SMS to the gSDP. It returns a String containing the SMSID of the sent SMS,
* in order to ask later for the status of the message.
* The max length of the message must be less than 160 characters.
*
* @param message the message to send via SMS. Message includes both message and message properties like senders, etc
* @return the sent SMS ID
* @throws BlueviaException
* @throws IOException
*/
protected String send(SmsMessageReq message) throws BlueviaException, IOException {
return sendSmsMessage(message);
}
}