Class: ChangeHealth::Response::Error
- Inherits:
-
Object
- Object
- ChangeHealth::Response::Error
- Defined in:
- lib/change_health/response/error.rb
Constant Summary collapse
- SIMPLE_RETRY_CODES =
%w[ 42 80 ].freeze
- NO_RESUBMIT_MESSAGES =
[ 'resubmission not allowed', 'do not resubmit' ].freeze
- DOWN_FIELD =
'Http Header'.freeze
- DOWN_MESSAGE =
'Please review http headers for this API, please contact support if you are unsure how to resolve.'.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #code_message ⇒ Object
- #field_message ⇒ Object
-
#initialize(data) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object
- #represents_down? ⇒ Boolean
- #retryable? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Error
Returns a new instance of Error.
20 21 22 |
# File 'lib/change_health/response/error.rb', line 20 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/change_health/response/error.rb', line 4 def data @data end |
Instance Method Details
#code_message ⇒ Object
32 33 34 |
# File 'lib/change_health/response/error.rb', line 32 def "#{code}: #{description}" if code? end |
#field_message ⇒ Object
28 29 30 |
# File 'lib/change_health/response/error.rb', line 28 def "#{field}: #{description}" if field? end |
#message ⇒ Object
24 25 26 |
# File 'lib/change_health/response/error.rb', line 24 def || || @data.to_s end |
#represents_down? ⇒ Boolean
36 37 38 |
# File 'lib/change_health/response/error.rb', line 36 def represents_down? field == DOWN_FIELD && description == DOWN_MESSAGE end |
#retryable? ⇒ Boolean
40 41 42 43 |
# File 'lib/change_health/response/error.rb', line 40 def retryable? represents_down? || (code? && SIMPLE_RETRY_CODES.include?(code) && can_follow_up?) end |