class Cb::Clients::Job

Public Class Methods

get(oauth_token, args = {}, use_v3_endpoint = false) click to toggle source
# File lib/cb/clients/job.rb, line 16
def get(oauth_token, args = {}, use_v3_endpoint = false)
  response = cb_client.cb_get(uri_get(args[:Did], use_v3_endpoint), headers: headers(oauth_token), query: args)
  not_found_check(response)
  response
end
report(args = {}) click to toggle source
# File lib/cb/clients/job.rb, line 22
def report(args = {})
  cb_client.cb_post(Cb.configuration.uri_report_job, body: report_body(args))
end

Private Class Methods

headers(oauth_token) click to toggle source
# File lib/cb/clients/job.rb, line 36
def headers(oauth_token)
  {
     'Accept' => 'application/json',
     'Authorization' => "Bearer #{ oauth_token }",
     'Content-Type' => 'application/json'
  }
end
not_found_check(response) click to toggle source
# File lib/cb/clients/job.rb, line 44
def not_found_check(response)
  return if response.nil?
  errors = Cb::Responses::Errors.new(response['ResponseJob'], false).parsed.join
  raise Cb::DocumentNotFoundError, errors if errors.downcase.include? 'job was not found'
end
report_body(args = {}) click to toggle source
# File lib/cb/clients/job.rb, line 50
        def report_body(args = {})
          <<-eos.gsub /^\s+/, ""
          <Request>
            <DeveloperKey>#{Cb.configuration.dev_key}</DeveloperKey>
            <JobDID>#{args[:job_id]}</JobDID>
            <UserID>#{args[:user_id]}</UserID>
            <ReportType>#{args[:report_type]}</ReportType>
            <Comments>#{args[:comments]}</Comments>
          </Request>
          eos
        end
uri_get(job_id, use_v3_endpoint) click to toggle source
# File lib/cb/clients/job.rb, line 28
def uri_get (job_id, use_v3_endpoint)
  if use_v3_endpoint
    Cb.configuration.uri_job_find_v3
  else
    "#{Cb.configuration.uri_job_find}/#{job_id}"
  end
end