Class: SmsManager::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_manager/client.rb

Instance Method Summary collapse

Instance Method Details

#send_message(options = {}) ⇒ Object

options should be { number: String, message: String }



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sms_manager/client.rb', line 7

def send_message(options = {})
  validate_send_message_options! options
  options = {
    username: SmsManager.instance_variable_get(:@username),
    password: SmsManager.instance_variable_get(:@hashed_password),
    number: options[:number],
    message: options[:message]
  }
  body = HTTPClient.get('http://http-api.smsmanager.cz/Send', options).body
  unless body =~ /^OK/
    raise SendingError, "Sending text '#{options[:message]}' to phone '#{options[:number]}' failed"
  end
  nil
end