Module: HellioMessaging

Defined in:
lib/helliomessaging_sms.rb,
lib/helliomessaging_sms/version.rb

Constant Summary collapse

VERSION =
"1.0.7"
@@api_username =
nil
@@api_password =
nil
@@api_comsumer_key =
nil
@@api_application_secret =
nil
@@api_senderid =
"HELLIOAPI"

Class Method Summary collapse

Class Method Details

.api_application_secretObject



60
# File 'lib/helliomessaging_sms.rb', line 60

def self.api_application_secret; @@api_application_secret; end

.api_application_secret=(api_application_secret) ⇒ Object



59
# File 'lib/helliomessaging_sms.rb', line 59

def self.api_application_secret=(api_application_secret); @@api_application_secret = api_application_secret; end

.api_consumer_keyObject



57
# File 'lib/helliomessaging_sms.rb', line 57

def self.api_consumer_key; @@api_consumer_key; end

.api_consumer_key=(api_consumer_key) ⇒ Object



56
# File 'lib/helliomessaging_sms.rb', line 56

def self.api_consumer_key=(api_consumer_key); @@api_consumer_key = api_consumer_key; end

.api_passwordObject



54
# File 'lib/helliomessaging_sms.rb', line 54

def self.api_password; @@api_password; end

.api_password=(api_password) ⇒ Object



53
# File 'lib/helliomessaging_sms.rb', line 53

def self.api_password=(api_password); @@api_password = api_password; end

.api_senderidObject



63
# File 'lib/helliomessaging_sms.rb', line 63

def self.api_senderid; @@api_senderid; end

.api_senderid=(api_senderid) ⇒ Object



62
# File 'lib/helliomessaging_sms.rb', line 62

def self.api_senderid=(api_senderid); @@api_senderid = api_senderid; end

.api_usernameObject



51
# File 'lib/helliomessaging_sms.rb', line 51

def self.api_username; @@api_username; end

.api_username=(api_username) ⇒ Object



50
# File 'lib/helliomessaging_sms.rb', line 50

def self.api_username=(api_username); @@api_username = api_username; end

.push(options = {}) ⇒ Object

Expects :msg, :to and an optional :from param The :from param defaults to @@api_senderid when its omitted

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/helliomessaging_sms.rb', line 15

def self.push(options={})

  sender_id = options[:from].nil? ? @@api_senderid : options[:from]
  response = nil
  message = options[:msg]

  raise ArgumentError, ':msg and :to params expected' if message.nil? || options[:to].nil?

  message = Nokogiri::HTML.parse(message).text

  # Send SMS Using the old form of Authentication [Username and Password]
  if @@api_username != nil && @@api_password != nil
    response = CurbFu.get({:host => 'app.helliomessaging.com/api', :path => '/sms?'}, { :from => sender_id, :to => options[:to], :text => message, :username => @@api_username, :password => @@api_password })
  end

  # Check Your Account Balance
  if @@api_username != nil && @@api_password != nil
    response = CurbFu.get({:host => 'app.helliomessaging.com/api', :path => '/sms-bal?'}, { :username => @@api_username, :password => @@api_password })
  end

  # Send SMS Using the new form of Authentication [Consumer ID and an Application Serect]
  if @@api_consumer_key != nil && @@api_application_secret != nil
    response = CurbFu.get({:host => 'app.helliomessaging.com/api', :path => '/sms-dlr?', :protocol => 'http'}, { :From => sender_id, :To => options[:to], :Content => message, :ClientKey => @@api_consumer_key, :ApplicationSecret => @@api_application_secret })
  end

   # Check for DLR's [Consumer ID and an Application Serect or Username and Password]
  if @@api_consumer_key != nil && @@api_application_secret != nil
    response = CurbFu.get({:host => 'app.helliomessaging.com/api', :path => '/sms-dlr?', :protocol => 'http'}, { :From => sender_id, :To => options[:to], :Content => message, :ClientKey => @@api_consumer_key, :ApplicationSecret => @@api_application_secret })
  end

  {:status => response.status, :notice => response.body}

end