class Lox24::Sms

Public Class Methods

create(msg={}) click to toggle source
# File lib/lox24/sms.rb, line 4
def self.create(msg={})
  uri = URI('https://www.lox24.eu/api/httpsms.php')
  res = Net::HTTP.post_form(uri,
    action: Lox24::Config.debug ? 'info': 'send',
    konto: Lox24::Config.client,
    password: Lox24::Config.password_hash,
    service: Lox24::Config.service,
    return: 'xml',
    text: msg[:text],
    to: msg[:to],
    from: msg[:from]
  )

  xml = XmlSimple.xml_in(res.body)
  code = xml['code'].first.to_i
  if code < 200
    xml['info'].first['MSGID'].first
  else
    false
  end

end