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
- .api_password ⇒ Object
- .api_password=(api_password) ⇒ Object
- .api_senderid ⇒ Object
- .api_senderid=(api_senderid) ⇒ Object
- .api_username ⇒ Object
- .api_username=(api_username) ⇒ Object
-
.push(options = {}) ⇒ Object
Expects :msg, :to and an optional :from param The :from param defaults to @@api_senderid when its omitted.
Class Method Details
.api_password ⇒ Object
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_senderid ⇒ Object
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_username ⇒ Object
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
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/smsgh_sms.rb', line 13 def self.push(={}) sender_id = [:from].nil? ? @@api_senderid : [:from] api_base = "#{API_URL}&username=#{@@api_username}&password=#{@@api_password}&from=#{sender_id}" url = "#{api_base}&text=#{CGI.escape([:msg])}&to=#{[:to]}" raise ArgumentError, ':msg and :to params expected' if [:msg].nil? || [:to].nil? response = CurbFu.get(url) {:status => response.status, :notice => response.body} end |