Class: Smartsheet::API::FaradayErrorResponse

Inherits:
FaradayResponse show all
Defined in:
lib/smartsheet/api/faraday_adapter/faraday_response.rb

Overview

Provides a Smartsheet error response from a Faraday response environment

Constant Summary collapse

RETRYABLE_ERRORS =
4001..4004

Instance Attribute Summary collapse

Attributes inherited from FaradayResponse

#headers, #reason_phrase, #status_code

Instance Method Summary collapse

Methods inherited from FaradayResponse

from_response_env

Constructor Details

#initialize(result, faraday_env) ⇒ FaradayErrorResponse

Returns a new instance of FaradayErrorResponse.



35
36
37
38
39
40
41
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 35

def initialize(result, faraday_env)
  super(faraday_env)
  @error_code = result[:errorCode]
  @message = result[:message]
  @ref_id = result[:refId]
  @detail = result[:detail]
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



33
34
35
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 33

def detail
  @detail
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



33
34
35
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 33

def error_code
  @error_code
end

#messageObject (readonly)

Returns the value of attribute message.



33
34
35
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 33

def message
  @message
end

#ref_idObject (readonly)

Returns the value of attribute ref_id.



33
34
35
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 33

def ref_id
  @ref_id
end

Instance Method Details

#should_retry?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 43

def should_retry?
  RETRYABLE_ERRORS.include? error_code
end

#success?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/smartsheet/api/faraday_adapter/faraday_response.rb', line 47

def success?
  false
end