class Sistrix::Monitoring::Report::Download

Attributes

data[R]
error[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/sistrix/monitoring/report/download.rb, line 13
def initialize(options = {})
  @data, @error = nil, nil

  @options = {
    'project' => nil,
    'report' => nil,
    'date' => 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/download.rb, line 29
def call(options = {})
  @options.merge!(options)

  response = RestClient.get(base_uri, { :params =>  @options })

  begin
    xml = Nokogiri::XML(response.to_s)
    @error = Error.new(xml.xpath('/response/error').first)
  rescue Exception => ex
    @data = response.to_s
  end

  self
end
error?() click to toggle source
# File lib/sistrix/monitoring/report/download.rb, line 44
def error?
  ! @error.nil?
end