Class: Cellular::Backends::CoolSMS

Inherits:
Object
  • Object
show all
Defined in:
lib/cellular/backends/cool_sms.rb

Constant Summary collapse

GATEWAY_URL =
'https://sms.coolsmsc.dk/'

Class Method Summary collapse

Class Method Details

.deliver(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cellular/backends/cool_sms.rb', line 10

def self.deliver(options = {})
  query = {
    username: Cellular.config.username,
    password: Cellular.config.password,
    from: options[:sender],
    to: options[:recipient],
    message: options[:message],
    charset: 'utf-8',
    resulttype: 'xml',
    lang: 'en'
  }

  result = HTTParty.get(GATEWAY_URL, query: query)
  response = result.parsed_response['smsc']

  [
    response['status'],
    response['result'] || response['message']['result']
  ]
end