Class: Sem4r::ReportJob

Inherits:
Base
  • Object
show all
Defined in:
lib/sem4r/v13_report/report_job.rb

Instance Attribute Summary

Attributes inherited from Base

#adwords, #credentials, #service

Instance Method Summary collapse

Methods inherited from Base

#add_counters

Methods included from Sem4rSoap::SoapAttributes

#_from_element, #_to_s, #_to_xml, included

Constructor Details

#initialize(report, job_id) ⇒ ReportJob

Returns a new instance of ReportJob.



27
28
29
30
# File 'lib/sem4r/v13_report/report_job.rb', line 27

def initialize(report, job_id)
  super( report.adwords, report.credentials )
  @job_id = job_id
end

Instance Method Details

#statusObject



42
43
44
45
46
47
48
# File 'lib/sem4r/v13_report/report_job.rb', line 42

def status
  soap_message = service.report.status(credentials, @job_id)
  add_counters( soap_message.counters )
  el = soap_message.response.xpath("//getReportJobStatusResponse/getReportJobStatusReturn").first
  status = el.text
  status
end

#wait(sleep_interval = 10, &block) ⇒ Object

Raises:

  • (Sem4Error)


32
33
34
35
36
37
38
39
40
# File 'lib/sem4r/v13_report/report_job.rb', line 32

def wait(sleep_interval = 10, &block)
  status = nil
  while status != "Completed" && status != 'Failed'
    sleep(sleep_interval)
    status = self.status
    block.call(self, status) if block
  end
  raise Sem4Error, "Report failed" if status == 'Failed'
end