Module: SmsManager

Defined in:
lib/sms_manager.rb,
lib/sms_manager/version.rb,
lib/sms_manager/error/sending_error.rb

Defined Under Namespace

Classes: SendingError, Version

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hashed_password=(value) ⇒ Object (writeonly)

Sets the attribute hashed_password

Parameters:

  • value

    the value to set the attribute hashed_password to.



6
7
8
# File 'lib/sms_manager.rb', line 6

def hashed_password=(value)
  @hashed_password = value
end

.username=(value) ⇒ Object (writeonly)

Sets the attribute username

Parameters:

  • value

    the value to set the attribute username to.



6
7
8
# File 'lib/sms_manager.rb', line 6

def username=(value)
  @username = value
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (SmsManager)

    the object that the method was called on



8
9
10
# File 'lib/sms_manager.rb', line 8

def configure
  yield self
end

.send(options = {}) ⇒ Object

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

Raises:



13
14
15
16
17
18
19
20
21
22
# File 'lib/sms_manager.rb', line 13

def send(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
  raise SendingError.new(options, body) unless body =~ /^OK/
end

.send_message(options = {}) ⇒ Object



24
25
26
# File 'lib/sms_manager.rb', line 24

def send_message(options = {})
  send options
end