Module: TurboSMS

Defined in:
lib/turbosms.rb,
lib/turbosms/api.rb,
lib/turbosms/error.rb,
lib/turbosms/client.rb,
lib/turbosms/options.rb,
lib/turbosms/version.rb

Defined Under Namespace

Classes: AuthError, SendingSMSError

Constant Summary collapse

60*60*12
VERSION =
'0.1.5'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_optionsObject

Returns the value of attribute default_options.



3
4
5
# File 'lib/turbosms/options.rb', line 3

def default_options
  @default_options
end

Class Method Details

.balanceObject



3
4
5
6
# File 'lib/turbosms/api.rb', line 3

def balance
  authorize unless authorized?
  authorised_call(:get_credit_balance).to_f
end

.get_message_status(message_id) ⇒ Object



8
9
10
11
12
# File 'lib/turbosms/api.rb', line 8

def get_message_status(message_id)
  authorize unless authorized?
  message = { 'MessageId' => message_id }
  authorised_call(:get_message_status, message: message)
end

.send_sms(destination, text = nil, sender = nil) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/turbosms/api.rb', line 14

def send_sms(destination, text = nil, sender = nil)
  authorize unless authorized?
  message = {
    sender:       sender || default_options[:sender],
    destination:  destination,
    text:         text
  }
  result = authorised_call(:send_sms, message: message)
  raise SendingSMSError, result unless result.instance_of?(Array)
  result[1] # message id
end