Module: SmsghSms

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

Constant Summary collapse

API_URL =
"http://api.smsgh.com/v2/messages/send?"
VERSION =
"1.0.2"
@@api_username =
nil
@@api_password =
nil
@@api_senderid =
"SMSGHAPI"

Class Method Summary collapse

Class Method Details

.api_passwordObject



30
# File 'lib/smsgh_sms.rb', line 30

def self.api_password; @@api_password; end

.api_password=(api_password) ⇒ Object



29
# File 'lib/smsgh_sms.rb', line 29

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

.api_senderidObject



32
# File 'lib/smsgh_sms.rb', line 32

def self.api_senderid; @@api_senderid; end

.api_senderid=(api_senderid) ⇒ Object



31
# File 'lib/smsgh_sms.rb', line 31

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

.api_usernameObject



28
# File 'lib/smsgh_sms.rb', line 28

def self.api_username; @@api_username; end

.api_username=(api_username) ⇒ Object



27
# File 'lib/smsgh_sms.rb', line 27

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)


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

def self.push(options={})
  
  sender_id = options[:from].nil? ? @@api_senderid : options[:from]
  api_base = "#{API_URL}&username=#{@@api_username}&password=#{@@api_password}&from=#{sender_id}"
  
  url = "#{api_base}&text=#{CGI.escape(options[:msg])}&to=#{options[:to]}"
  raise ArgumentError, ':msg and :to params expected' if options[:msg].nil? || options[:to].nil?
  
  response = CurbFu.get(url)
  {:status => response.status, :notice => response.body}
  
end