Class: Sappy::Account
- Inherits:
-
Object
- Object
- Sappy::Account
- Defined in:
- lib/sappy/account.rb
Instance Attribute Summary collapse
-
#authkey ⇒ Object
readonly
Returns the value of attribute authkey.
-
#available_monitors ⇒ Object
readonly
Returns the value of attribute available_monitors.
-
#down_monitors ⇒ Object
readonly
Returns the value of attribute down_monitors.
-
#inactive_monitors ⇒ Object
readonly
Returns the value of attribute inactive_monitors.
-
#setup_monitors ⇒ Object
readonly
Returns the value of attribute setup_monitors.
-
#sms_alerts ⇒ Object
readonly
Returns the value of attribute sms_alerts.
-
#up_monitors ⇒ Object
readonly
Returns the value of attribute up_monitors.
Class Method Summary collapse
Instance Method Summary collapse
- #add_monitor(attributes) ⇒ Object
- #authenticated? ⇒ Boolean
- #connect(forced = false) ⇒ Object
-
#initialize(username, password) ⇒ Account
constructor
A new instance of Account.
- #login ⇒ Object
- #monitors(ids = []) ⇒ Object
- #refresh! ⇒ Object
- #request(action, parameters = {}) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Account
Returns a new instance of Account.
12 13 14 |
# File 'lib/sappy/account.rb', line 12 def initialize(username, password) @username, @password = username, password end |
Instance Attribute Details
#authkey ⇒ Object (readonly)
Returns the value of attribute authkey.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def authkey @authkey end |
#available_monitors ⇒ Object (readonly)
Returns the value of attribute available_monitors.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def available_monitors @available_monitors end |
#down_monitors ⇒ Object (readonly)
Returns the value of attribute down_monitors.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def down_monitors @down_monitors end |
#inactive_monitors ⇒ Object (readonly)
Returns the value of attribute inactive_monitors.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def inactive_monitors @inactive_monitors end |
#setup_monitors ⇒ Object (readonly)
Returns the value of attribute setup_monitors.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def setup_monitors @setup_monitors end |
#sms_alerts ⇒ Object (readonly)
Returns the value of attribute sms_alerts.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def sms_alerts @sms_alerts end |
#up_monitors ⇒ Object (readonly)
Returns the value of attribute up_monitors.
3 4 5 |
# File 'lib/sappy/account.rb', line 3 def up_monitors @up_monitors end |
Class Method Details
.login(username, password) ⇒ Object
6 7 8 9 10 |
# File 'lib/sappy/account.rb', line 6 def self.login(username, password) account = new(username, password) account.login account end |
Instance Method Details
#add_monitor(attributes) ⇒ Object
44 45 46 |
# File 'lib/sappy/account.rb', line 44 def add_monitor(attributes) Monitor.create(self, attributes) end |
#authenticated? ⇒ Boolean
21 22 23 |
# File 'lib/sappy/account.rb', line 21 def authenticated? @authkey end |
#connect(forced = false) ⇒ Object
25 26 27 28 29 |
# File 'lib/sappy/account.rb', line 25 def connect(forced = false) if !authenticated? or forced authenticate end end |
#login ⇒ Object
16 17 18 19 |
# File 'lib/sappy/account.rb', line 16 def login connect refresh! end |
#monitors(ids = []) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/sappy/account.rb', line 36 def monitors(ids = []) params = ids.any? ? { "MonitorId" => ids.join(',') } : {} response = request('monitors', params) response.monitors.map do |m| Monitor.parse(self, m) end end |
#refresh! ⇒ Object
31 32 33 34 |
# File 'lib/sappy/account.rb', line 31 def refresh! refresh_account_info refresh_summary_statistics end |