Class: SmsMisr::Handler

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sms_misr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phone_number) ⇒ Handler

Returns a new instance of Handler.



16
17
18
19
20
21
22
23
24
25
# File 'lib/sms_misr.rb', line 16

def initialize(phone_number)
  @options = {
    query:
    {
      username: username,
      password: password,
      mobile: phone_number,
    },
  }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/sms_misr.rb', line 14

def options
  @options
end

Instance Method Details

#send_message(message, sender, language = 1) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/sms_misr.rb', line 27

def send_message(message, sender, language = 1)
  return unenabled_message unless send_sms_enabled?

  @options[:query].merge!(message_params(message, sender, language))
  result = self.class.post('/webapi', @options)
  result.parsed_response
end

#send_otp(otp) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/sms_misr.rb', line 35

def send_otp(otp)
  return unenabled_message unless send_sms_enabled?

  @options[:query].merge!(otp_params(otp))
  result = self.class.post('/vSMS', @options)
  result.parsed_response
end