Class: GoApiClient::Api::Job

Inherits:
AbstractApi show all
Defined in:
lib/go_api_client/api/job.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Job

Returns a new instance of Job.



7
8
9
# File 'lib/go_api_client/api/job.rb', line 7

def initialize(attributes = {})
  super(attributes)
end

Instance Method Details

#job(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/go_api_client/api/job.rb', line 11

def job(options = {})
  if options[:job_uri]
    uri = options[:job_uri]
  else
    raise 'Insufficient arguments' unless options[:job_id]
    uri = "#{@base_uri}/api/jobs/#{options[:job_id]}.xml"
  end
  GoApiClient::Parsers::Job.parse(Nokogiri::XML(@http_fetcher.get!(uri)).root)
end

#scheduled_jobsObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/go_api_client/api/job.rb', line 21

def scheduled_jobs
  uri = "#{@base_uri}/api/jobs/scheduled.xml"
  doc = Nokogiri::XML(@http_fetcher.post!(uri))
  if doc.root
    doc.root.xpath('./job').collect do |element|
      GoApiClient::Parsers::ScheduledJob.parse(element)
    end
  else
    []
  end
end