Class: Retab::ApiCallAttempt

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/workflow_artifacts/api_call_attempt.rb

Constant Summary collapse

HASH_ATTRS =
{
  attempt_number: :attempt_number,
  request_method: :request_method,
  request_url: :request_url,
  request_headers: :request_headers,
  request_body: :request_body,
  response_status: :response_status,
  response_headers: :response_headers,
  response_body: :response_body,
  duration_ms: :duration_ms,
  error: :error,
  started_at: :started_at,
  completed_at: :completed_at
}.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) ⇒ ApiCallAttempt

Returns a new instance of ApiCallAttempt.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 37

def initialize(json)
  hash = self.class.normalize(json)
  @attempt_number = hash[:attempt_number]
  @request_method = hash[:request_method]
  @request_url = hash[:request_url]
  @request_headers = hash[:request_headers] || {}
  @request_body = hash[:request_body]
  @response_status = hash[:response_status]
  @response_headers = hash[:response_headers] || {}
  @response_body = hash[:response_body]
  @duration_ms = hash[:duration_ms]
  @error = hash[:error] ? Retab::ErrorDetails.new(hash[:error]) : nil
  @started_at = hash[:started_at]
  @completed_at = hash[:completed_at]
end

Instance Attribute Details

#attempt_numberObject

Returns the value of attribute attempt_number.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def attempt_number
  @attempt_number
end

#completed_atObject

Returns the value of attribute completed_at.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def completed_at
  @completed_at
end

#duration_msObject

Returns the value of attribute duration_ms.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def duration_ms
  @duration_ms
end

#errorObject

Returns the value of attribute error.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def error
  @error
end

#request_bodyObject

Returns the value of attribute request_body.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def request_body
  @request_body
end

#request_headersObject

Returns the value of attribute request_headers.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def request_headers
  @request_headers
end

#request_methodObject

Returns the value of attribute request_method.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def request_method
  @request_method
end

#request_urlObject

Returns the value of attribute request_url.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def request_url
  @request_url
end

#response_bodyObject

Returns the value of attribute response_body.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def response_body
  @response_body
end

#response_headersObject

Returns the value of attribute response_headers.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def response_headers
  @response_headers
end

#response_statusObject

Returns the value of attribute response_status.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def response_status
  @response_status
end

#started_atObject

Returns the value of attribute started_at.



23
24
25
# File 'lib/retab/workflow_artifacts/api_call_attempt.rb', line 23

def started_at
  @started_at
end