Class: FrederickAPI::V2::BackgroundJob

Inherits:
Resource
  • Object
show all
Defined in:
lib/frederick_api/v2/background_job.rb

Overview

V2 Frederick API async background job class for parsing background job responses coming from API.

Instance Attribute Summary collapse

Attributes inherited from Resource

#custom_headers

Instance Method Summary collapse

Methods inherited from Resource

_header_store, all_records, custom_headers, #initialize, site, top_level_namespace, with_access_token, with_access_token_and_headers

Constructor Details

This class inherits a constructor from FrederickAPI::V2::Resource

Instance Attribute Details

#responseObject

Returns the value of attribute response.



8
9
10
# File 'lib/frederick_api/v2/background_job.rb', line 8

def response
  @response
end

Instance Method Details

#errorsObject



27
28
29
# File 'lib/frederick_api/v2/background_job.rb', line 27

def errors
  @attributes['messages']
end

#has_errors?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/frederick_api/v2/background_job.rb', line 10

def has_errors?
  @attributes['status'] == 'error'
end

#idObject



31
32
33
# File 'lib/frederick_api/v2/background_job.rb', line 31

def id
  @attributes['id']
end

#response_codeObject



19
20
21
# File 'lib/frederick_api/v2/background_job.rb', line 19

def response_code
  @response_code ||= @response[:status]
end

#retry_afterObject



14
15
16
17
# File 'lib/frederick_api/v2/background_job.rb', line 14

def retry_after
  try_time = @response[:headers]['retry-after'].to_i
  @retry_after ||= try_time > 1 ? try_time : 1
end

#statusObject



23
24
25
# File 'lib/frederick_api/v2/background_job.rb', line 23

def status
  @attributes['status']
end