Class: AdvancedBilling::ProformaBadRequestErrorResponseException

Inherits:
APIException
  • Object
show all
Defined in:
lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb

Overview

Proforma Bad Request Error Response class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ ProformaBadRequestErrorResponseException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



19
20
21
22
23
# File 'lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb', line 19

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#errorsProformaError

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb', line 14

def errors
  @errors
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



41
42
43
44
# File 'lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb', line 41

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} errors: #{@errors.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



35
36
37
38
# File 'lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb', line 35

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} errors: #{@errors}>"
end

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • hash (Hash)

    The deserialized response sent by the server in the



28
29
30
31
32
# File 'lib/advanced_billing/exceptions/proforma_bad_request_error_response_exception.rb', line 28

def unbox(hash)
  return nil unless hash

  @errors = ProformaError.from_hash(hash['errors']) if hash['errors']
end