Class: Retab::Job

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/jobs/job.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  object: :object,
  status: :status,
  endpoint: :endpoint,
  error: :error,
  warnings: :warnings,
  created_at: :created_at,
  started_at: :started_at,
  completed_at: :completed_at,
  expires_at: :expires_at,
  metadata: :metadata,
  cancelled: :cancelled,
  attempt_count: :attempt_count,
  last_attempt_at: :last_attempt_at,
  last_failure_code: :last_failure_code,
  request: :request,
  response: :response
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

#inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ Job

Returns a new instance of Job.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/retab/jobs/job.rb', line 47

def initialize(json)
  hash = self.class.normalize(json)
  @id = hash[:id]
  @object = hash[:object]
  @status = hash[:status]
  @endpoint = hash[:endpoint]
  @error = hash[:error] ? Retab::JobError.new(hash[:error]) : nil
  @warnings = (hash[:warnings] || []).map { |item| item ? Retab::JobWarning.new(item) : nil }
  @created_at = hash[:created_at]
  @started_at = hash[:started_at]
  @completed_at = hash[:completed_at]
  @expires_at = hash[:expires_at]
  @metadata = hash[:metadata] || {}
  @cancelled = hash[:cancelled]
  @attempt_count = hash[:attempt_count]
  @last_attempt_at = hash[:last_attempt_at]
  @last_failure_code = hash[:last_failure_code]
  @request = hash[:request] || {}
  @response = hash[:response] ? Retab::JobResponse.new(hash[:response]) : nil
end

Instance Attribute Details

#attempt_countObject

Returns the value of attribute attempt_count.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def attempt_count
  @attempt_count
end

#cancelledObject

Returns the value of attribute cancelled.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def cancelled
  @cancelled
end

#completed_atObject

Returns the value of attribute completed_at.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def completed_at
  @completed_at
end

#created_atObject

Returns the value of attribute created_at.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def created_at
  @created_at
end

#endpointObject

Returns the value of attribute endpoint.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def endpoint
  @endpoint
end

#errorObject

Returns the value of attribute error.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def error
  @error
end

#expires_atObject

Returns the value of attribute expires_at.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def expires_at
  @expires_at
end

#idObject

Returns the value of attribute id.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def id
  @id
end

#last_attempt_atObject

Returns the value of attribute last_attempt_at.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def last_attempt_at
  @last_attempt_at
end

#last_failure_codeObject

Returns the value of attribute last_failure_code.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def last_failure_code
  @last_failure_code
end

#metadataObject

Returns the value of attribute metadata.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def 
  @metadata
end

#objectObject

Returns the value of attribute object.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def object
  @object
end

#requestObject

Returns the value of attribute request.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def request
  @request
end

#responseObject

Returns the value of attribute response.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def response
  @response
end

#started_atObject

Returns the value of attribute started_at.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def started_at
  @started_at
end

#statusObject

Returns the value of attribute status.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def status
  @status
end

#warningsObject

Returns the value of attribute warnings.



28
29
30
# File 'lib/retab/jobs/job.rb', line 28

def warnings
  @warnings
end