48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# 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
|