class SMSRetrieve

Public Class Methods

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

Public Instance Methods

cancelReceiptNotifications(subscriptionId) click to toggle source
# File lib/sms/SMSRetrieve.rb, line 105
def cancelReceiptNotifications(subscriptionId)
  baseurl=@endpoints.getCancelSMSReceiptSubscriptionEndpoint()
  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/SMSRetrieve.rb, line 20
def getEndpoints
  @endpoints
end
getPassword() click to toggle source
# File lib/sms/SMSRetrieve.rb, line 36
def getPassword
  @password
end
getUsername() click to toggle source
# File lib/sms/SMSRetrieve.rb, line 28
def getUsername
  @username
end
retrieveMessages(registrationId,maxBatchSize) click to toggle source
# File lib/sms/SMSRetrieve.rb, line 45
def retrieveMessages(registrationId,maxBatchSize)
  baseurl=@endpoints.getRetrieveSMSEndpoint()
  requestProcessor=JSONRequest.new()
  if baseurl.index('{registrationId}')!=nil then
    baseurl=baseurl.gsub('{registrationId}',CGI::escape(registrationId.to_s))
  end
  if baseurl.index('{maxBatchSize}')!=nil then
    baseurl=baseurl.gsub('{maxBatchSize}',CGI::escape(maxBatchSize.to_s))
  end
  rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
  response=RetrieveSMSResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['inboundSMSMessageList']!=nil) then
      response.setInboundSMSMessageListJSON(jsondata['inboundSMSMessageList'])
    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/SMSRetrieve.rb, line 24
def setEndpoints(endpoints)
  @endpoints=endpoints
end
setPassword(password) click to toggle source
# File lib/sms/SMSRetrieve.rb, line 40
def setPassword(password)
  @password=password
end
setUsername(username) click to toggle source
# File lib/sms/SMSRetrieve.rb, line 32
def setUsername(username)
  @username=username
end
subscribeToReceiptNotifications(destinationAddress,notifyURL,criteria,notificationFormat,clientCorrelator,callbackData) click to toggle source
# File lib/sms/SMSRetrieve.rb, line 74
def subscribeToReceiptNotifications(destinationAddress,notifyURL,criteria,notificationFormat,clientCorrelator,callbackData)
  baseurl=@endpoints.getSMSReceiptSubscriptionsEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('destinationAddress',destinationAddress)
  formparameters.put('notifyURL',notifyURL)
  formparameters.put('criteria',criteria)
  formparameters.put('notificationFormat',notificationFormat)
  formparameters.put('clientCorrelator',clientCorrelator)
  formparameters.put('callbackData',callbackData)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=SMSMessageReceiptSubscriptionResponse.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