Class: LoyaltyApIs::JsonApiErrorException
- Inherits:
-
APIException
- Object
- CoreLibrary::ApiException
- APIException
- LoyaltyApIs::JsonApiErrorException
- Defined in:
- lib/loyalty_ap_is/exceptions/json_api_error_exception.rb
Overview
JSON API Error class.
Instance Attribute Summary collapse
-
#errors ⇒ Array[ErrorItem]
TODO: Write general description for this method.
-
#jsonapi ⇒ JsonApiVersion
TODO: Write general description for this method.
Instance Method Summary collapse
-
#initialize(reason, response) ⇒ JsonApiErrorException
constructor
The constructor.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, response) ⇒ JsonApiErrorException
The constructor.
23 24 25 26 27 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 23 def initialize(reason, response) super(reason, response) hash = APIHelper.json_deserialize(@response.raw_body) unbox(hash) end |
Instance Attribute Details
#errors ⇒ Array[ErrorItem]
TODO: Write general description for this method
18 19 20 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 18 def errors @errors end |
#jsonapi ⇒ JsonApiVersion
TODO: Write general description for this method
14 15 16 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 14 def jsonapi @jsonapi end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
55 56 57 58 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 55 def inspect class_name = self.class.name.split('::').last "<#{class_name} jsonapi: #{@jsonapi.inspect}, errors: #{@errors.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
49 50 51 52 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 49 def to_s class_name = self.class.name.split('::').last "<#{class_name} jsonapi: #{@jsonapi}, errors: #{@errors}>" end |
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/loyalty_ap_is/exceptions/json_api_error_exception.rb', line 32 def unbox(hash) return nil unless hash @jsonapi = JsonApiVersion.from_hash(hash['jsonapi']) if hash['jsonapi'] # Parameter is an array, so we need to iterate through it @errors = nil unless hash['errors'].nil? @errors = [] hash['errors'].each do |structure| @errors << (ErrorItem.from_hash(structure) if structure) end end @errors = SKIP unless hash.key?('errors') end |