class SMSSend

Public Class Methods

new(endpoints, username, password) click to toggle source
# File lib/sms/SMSSend.rb, line 18
def initialize(endpoints, username, password)
  @endpoints=endpoints
  @username=username
  @password=password
end

Public Instance Methods

cancelDeliveryNotifications(subscriptionId) click to toggle source
# File lib/sms/SMSSend.rb, line 148
def cancelDeliveryNotifications(subscriptionId)
  baseurl=@endpoints.getCancelSMSDeliverySubscriptionEndpoint()
  requestProcessor=JSONRequest.new()
  if baseurl.index('{subscriptionId}')!=nil then
    baseurl=baseurl.gsub('{subscriptionId}',CGI::escape(subscriptionId.to_s))
  end
  rawresponse=requestProcessor.delete(baseurl,@username,@password)
  response=HTTPResponse.new()
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
getEndpoints() click to toggle source
# File lib/sms/SMSSend.rb, line 23
def getEndpoints
  @endpoints
end
getPassword() click to toggle source
# File lib/sms/SMSSend.rb, line 39
def getPassword
  @password
end
getUsername() click to toggle source
# File lib/sms/SMSSend.rb, line 31
def getUsername
  @username
end
queryDeliveryStatus(senderAddress,requestId) click to toggle source
# File lib/sms/SMSSend.rb, line 87
def queryDeliveryStatus(senderAddress,requestId)
  baseurl=@endpoints.getQuerySMSDeliveryEndpoint()
  requestProcessor=JSONRequest.new()
  if baseurl.index('{senderAddress}')!=nil then
    baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
  end
  if baseurl.index('{requestId}')!=nil then
    baseurl=baseurl.gsub('{requestId}',CGI::escape(requestId.to_s))
  end
  rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
  response=SMSSendDeliveryStatusResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['deliveryInfoList']!=nil) then
      response.setDeliveryInfoListJSON(jsondata['deliveryInfoList'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
sendSMS(senderAddress,address,message,clientCorrelator,notifyURL,senderName,callbackData) click to toggle source
# File lib/sms/SMSSend.rb, line 48
def sendSMS(senderAddress,address,message,clientCorrelator,notifyURL,senderName,callbackData)
  baseurl=@endpoints.getSendSMSEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('senderAddress',senderAddress)
  if baseurl.index('{senderAddress}')!=nil then
    baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
  end
  if address!=nil
    for item in address
      formparameters.put('address',item)
    end
  end
  formparameters.put('message',message)
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('notifyURL',notifyURL)
  formparameters.put('senderName',senderName)
  formparameters.put('callbackData',callbackData)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=SendSMSResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['resourceReference']!=nil) then
      response.setResourceReferenceJSON(jsondata['resourceReference'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end
setEndpoints(endpoints) click to toggle source
# File lib/sms/SMSSend.rb, line 27
def setEndpoints(endpoints)
  @endpoints=endpoints
end
setPassword(password) click to toggle source
# File lib/sms/SMSSend.rb, line 43
def setPassword(password)
  @password=password
end
setUsername(username) click to toggle source
# File lib/sms/SMSSend.rb, line 35
def setUsername(username)
  @username=username
end
subscribeToDeliveryNotifications(senderAddress,clientCorrelator,notifyURL,callbackData) click to toggle source
# File lib/sms/SMSSend.rb, line 116
def subscribeToDeliveryNotifications(senderAddress,clientCorrelator,notifyURL,callbackData)
  baseurl=@endpoints.getSMSDeliverySubscriptionsEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('senderAddress',senderAddress)
  if baseurl.index('{senderAddress}')!=nil then
    baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
  end
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('notifyURL',notifyURL)
  formparameters.put('callbackData',callbackData)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=SMSDeliveryReceiptSubscriptionResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['deliveryReceiptSubscription']!=nil) then
      response.setDeliveryReceiptSubscriptionJSON(jsondata['deliveryReceiptSubscription'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end