class SmsOwl
Constants
- URL
Public Class Methods
new(accountId,apiKey)
click to toggle source
# File lib/sms_owl.rb, line 16 def initialize(accountId,apiKey) @accountId = accountId @apiKey = apiKey end
Public Instance Methods
getCommonArray(dndType,smsType,senderId,to)
click to toggle source
# File lib/sms_owl.rb, line 63 def getCommonArray(dndType,smsType,senderId,to) return { accountId: @accountId, apiKey: @apiKey, dndType: dndType, smsType: smsType, senderId: senderId, to: to } end
sendPromotionalSms(senderId,to,message,smsType = SmsOwl::SmsType::NORMAL)
click to toggle source
# File lib/sms_owl.rb, line 21 def sendPromotionalSms(senderId,to,message,smsType = SmsOwl::SmsType::NORMAL) req = Net::HTTP::Post.new(SmsOwl::URL, initheader = {'Content-Type' =>'application/json'}) data = getCommonArray("promotional",smsType,senderId,to) data['message'] = message req.body = data.to_json res = Net::HTTP.start(URL.hostname, URL.port, :use_ssl => URL.scheme == 'https') do |http| http.request(req) end if res.code == '200' jsonRes = JSON.parse(res.body) if to.kind_of?(Array) return jsonRes["smsIds"] else return jsonRes["smsId"] end elsif res.code == '400' jsonRes = JSON.parse(res.body) raise jsonRes['message'] end end
sendTransactionalSms(senderId,to,templateId,placeholderArray)
click to toggle source
# File lib/sms_owl.rb, line 43 def sendTransactionalSms(senderId,to,templateId,placeholderArray) req = Net::HTTP::Post.new(SmsOwl::URL, initheader = {'Content-Type' =>'application/json'}) data = getCommonArray("transactional","normal",senderId,to) data['templateId'] = templateId data['placeholders'] = placeholderArray req.body = data.to_json res = Net::HTTP.start(URL.hostname, URL.port, :use_ssl => URL.scheme == 'https') do |http| http.request(req) end if res.code == '200' jsonRes = JSON.parse(res.body) return jsonRes["smsId"] elsif res.code == '400' jsonRes = JSON.parse(res.body) raise jsonRes['message'] end end