Module: HellioMessaging

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

Constant Summary collapse

VERSION =
"1.1.0"
@@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



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

def self.api_application_secret; @@api_application_secret; end

.api_application_secret=(api_application_secret) ⇒ Object



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

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

.api_consumer_keyObject



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

def self.api_consumer_key; @@api_consumer_key; end

.api_consumer_key=(api_consumer_key) ⇒ Object



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

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

.api_passwordObject



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

def self.api_password; @@api_password; end

.api_password=(api_password) ⇒ Object



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

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

.api_senderidObject



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

def self.api_senderid; @@api_senderid; end

.api_senderid=(api_senderid) ⇒ Object



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

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

.api_usernameObject



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

def self.api_username; @@api_username; end

.api_username=(api_username) ⇒ Object



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

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
48
49
50
51
52
53
54
# 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


  # 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?', :protocol => 'http'}, { :From => sender_id, :To => options[:to], :Content => message, :ConsumerKey => @@api_consumer_key, :ApplicationSecret => @@api_application_secret })
  end

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

  # Check Your Account Balance (New Authentication: Consumer Key and Application Secret)
  if @@api_consumer_key != nil && @@api_application_secret != nil
    response = CurbFu.get({:host => 'app.helliomessaging.com/api', :path => '/sms-bal?', :protocol => 'http'}, { :ConsumerKey => @@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, :ConsumerKey => @@api_consumer_key, :ApplicationSecret => @@api_application_secret })
  end

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

end