class Sms::Smsru

Attributes

smsru_api_id[RW]
test[RW]

Public Instance Methods

calc_cost() click to toggle source
# File lib/smster/sms/smsru.rb, line 8
def calc_cost
  extract_from(request_cost, /\n(.*)\n?/)
end

Private Instance Methods

assign_attrs_by(response) click to toggle source
# File lib/smster/sms/smsru.rb, line 29
def assign_attrs_by(response)
  self.status_message = response

  return unless response.include?('100')

  self.balance = extract_from(response, /.*\n.*\nbalance=(.*)/)
  self.api_message_id = extract_from(response, /\n(.*)\n?/)
end
extract_from(response, regexp) click to toggle source
# File lib/smster/sms/smsru.rb, line 47
def extract_from(response, regexp)
  value = (regexp).match(response)

  value && value[1]
end
modify_params() click to toggle source
# File lib/smster/sms/smsru.rb, line 14
def modify_params
  self.to = to.gsub(/\D/, '')
end
request_cost() click to toggle source
# File lib/smster/sms/smsru.rb, line 38
def request_cost
  RestClient.post(
    'http://sms.ru/sms/cost',
    'api_id' => smsru_api_id,
    'text' => text,
    'to' => to
  )
end
send_request() click to toggle source
# File lib/smster/sms/smsru.rb, line 18
def send_request
  RestClient.post(
    'http://sms.ru/sms/send',
    'api_id' => smsru_api_id,
    'text' => text,
    'to' => to,
    'from' => name,
    'test' => test
  )
end