Class: Sappy::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/sappy/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#authkeyObject (readonly)

Returns the value of attribute authkey.



3
4
5
# File 'lib/sappy/account.rb', line 3

def authkey
  @authkey
end

#available_monitorsObject (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_monitorsObject (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_monitorsObject (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_monitorsObject (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_alertsObject (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_monitorsObject (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.(username, password)
   = new(username, password)
  .
  
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

Returns:

  • (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

#loginObject



16
17
18
19
# File 'lib/sappy/account.rb', line 16

def 
  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_summary_statistics
end

#request(action, parameters = {}) ⇒ Object



48
49
50
# File 'lib/sappy/account.rb', line 48

def request(action, parameters = {})
  Request.perform(self, action, parameters)
end