class Sistrix::Monitoring::Report

Attributes

credits[R]
format[R]
frequency[R]
id[R]
name[R]
recipients[R]
reports[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/sistrix/monitoring/report.rb, line 11
def initialize(options = {})
  @options = {
    'project' => nil,
    'report' => nil,
    'api_key' => Sistrix.config.api_key,
  }.merge(options)

  if Sistrix.config.proxy
    RestClient.proxy = Sistrix.config.proxy
  end
end

Public Instance Methods

call(options = {}) click to toggle source
# File lib/sistrix/monitoring/report.rb, line 23
def call(options = {})
  data = fetch(options)

  @credits   = data.xpath('/response/credits').first['used'].to_i
  @name      = data.xpath('/response/answer/name').first['value'].to_s.strip
  @id        = data.xpath('/response/answer/id').first['value'].to_s.strip
  @frequency = data.xpath('/response/answer/frequency').first['value'].to_s.strip
  @format    = data.xpath('/response/answer/format').first['value'].to_s.strip

  @recipients = []
  data.xpath('/response/answer/recipients/recipient').each do |r|
    @recipients << Recipient.new(r)
  end

  @reports = []
  data.xpath('/response/answer/archive/report').each do |r|
    @reports << Record.new(r)
  end

  self
end