@param callbackData (optional) is a function name or other data that you would like included when the POST is sent to your application
@see SMSMessageReceiptSubscriptionResponse
*/
public SMSMessageReceiptSubscriptionResponse subscribeToReceiptNotifications(String destinationAddress, String notifyURL, String criteria, String notificationFormat, String clientCorrelator, String callbackData) {
SMSMessageReceiptSubscriptionResponse response=new SMSMessageReceiptSubscriptionResponse();
if (destinationAddress!=null && notifyURL!=null) {
FormParameters formParameters=new FormParameters();
formParameters.put("destinationAddress", destinationAddress);
formParameters.put("notifyURL", notifyURL);
formParameters.put("criteria", criteria);
formParameters.put("notificationFormat", notificationFormat);
formParameters.put("clientCorrelator", clientCorrelator);
formParameters.put("callbackData", callbackData);
int responseCode=0;
String contentType = null;
try {
String endpoint=endPoints.getSMSReceiptSubscriptionsEndpoint();
if (dumpRequestAndResponse) JSONRequest.dumpRequestVariables(endpoint, authorisationHeader, formParameters);
HttpURLConnection con = JSONRequest.setupConnection(endpoint, authorisationHeader);
con.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
String requestBody=JSONRequest.formEncodeParams(formParameters);
out.write(requestBody);
out.close();
responseCode=con.getResponseCode();
contentType = con.getContentType();
response=smsMessageReceiptSubscriptionProcessor.getResponse(con, OneAPIServlet.CREATED);
} catch (Exception e) {
response.setHTTPResponseCode(responseCode);
response.setContentType(contentType);
response.setRequestError(new RequestError(RequestError.SERVICEEXCEPTION, "SVCJAVA", e.getMessage(), e.getClass().getName()));
logger.error("Exception "+e.getMessage()+" "+e.getLocalizedMessage());
}
}
return response;