Class: VoodooSMS
Overview
TODO: RDoc
Defined Under Namespace
Modules: Error
Instance Method Summary collapse
- #get_credit ⇒ Object
- #get_sms(from, to, keyword = '') ⇒ Object
-
#initialize(username, password) ⇒ VoodooSMS
constructor
A new instance of VoodooSMS.
- #send_sms(originator, destination, message) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ VoodooSMS
Returns a new instance of VoodooSMS.
21 22 23 |
# File 'lib/voodoo_sms.rb', line 21 def initialize(username, password) @params = { query: { uid: username, pass: password } } end |
Instance Method Details
#get_credit ⇒ Object
25 26 27 |
# File 'lib/voodoo_sms.rb', line 25 def get_credit make_request('getCredit')['credit'] end |
#get_sms(from, to, keyword = '') ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/voodoo_sms.rb', line 34 def get_sms(from, to, keyword = '') merge_params(from: format_date(from), to: format_date(to), keyword: keyword) response = make_request('getSMS')['messages'] if response.is_a?(Array) response.map { |r| OpenStruct.new(from: r['Originator'], timestamp: DateTime.parse(r['TimeStamp']), message: r['Message']) } else [] end end |
#send_sms(originator, destination, message) ⇒ Object
29 30 31 32 |
# File 'lib/voodoo_sms.rb', line 29 def send_sms(originator, destination, ) merge_params(orig: originator, dest: destination, msg: , validity: 1) make_request('sendSMS')['resultText'].to_s.include? 'OK' end |