Class: Every8d::Client
- Inherits:
-
Object
- Object
- Every8d::Client
- Defined in:
- lib/every8d/client.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
- #get_balance ⇒ Object
- #get_message(options = {}) ⇒ Object
- #http_post(url, data = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #send_sms(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/every8d/client.rb', line 7 def initialize( = {}) @uid = .fetch(:UID) { ENV.fetch('EVERY8d_ACCOUNT') } @pwd = .fetch(:PWD) { ENV.fetch('EVERY8d_PASSWORD') } @host = .fetch(:host) { 'http://api.every8d.com/API21/HTTP' } end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
5 6 7 |
# File 'lib/every8d/client.rb', line 5 def account @account end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/every8d/client.rb', line 5 def password @password end |
Instance Method Details
#get_balance ⇒ Object
19 20 21 |
# File 'lib/every8d/client.rb', line 19 def get_balance http_post('getCredit.ashx') end |
#get_message(options = {}) ⇒ Object
15 16 17 |
# File 'lib/every8d/client.rb', line 15 def ( = {}) http_post('getDeliveryStatus.ashx', ) end |
#http_post(url, data = {}) ⇒ Object
27 28 29 |
# File 'lib/every8d/client.rb', line 27 def http_post(url, data = {}) Net::HTTP.post_form(URI.parse("#{@host}/#{url}"), data.merge(UID: @uid, PWD: @pwd)).body end |
#send_sms(options = {}) ⇒ Object
23 24 25 |
# File 'lib/every8d/client.rb', line 23 def send_sms( = {}) http_post('sendSMS.ashx', ) end |