class Sms::Clickatell

Attributes

clickatell_key[RW]
unicode[RW]

Private Instance Methods

assign_attrs_by(response) click to toggle source
# File lib/smster/sms/clickatell.rb, line 39
def assign_attrs_by(response)
  response = JSON.parse(response)

  info = response['data']['message'][0]

  self.status_message = info['error']
  self.api_message_id = info['apiMessageId']
end
modify_params() click to toggle source
# File lib/smster/sms/clickatell.rb, line 10
def modify_params
  self.to = to.gsub(/\D/, '').to_s
  self.text = text.tr(' ', '+')
end
send_request() click to toggle source
# File lib/smster/sms/clickatell.rb, line 15
def send_request
  msg_params = {
    'text' => text,
    'to' => [to],
    'unicode' => unicode,
    'from' => name
  }.to_json

  start_request(msg_params)
end
start_request(params) click to toggle source
# File lib/smster/sms/clickatell.rb, line 26
def start_request(params)
  RestClient.post(
    'https://api.clickatell.com/rest/message',
    params,
    content_type: :json,
    accept: :json,
    'X-Version' => 1,
    'Authorization' => "bearer #{clickatell_key}"
  )
rescue => e
  e.response
end