Class: Amsi::Validator::RequestErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/amsi/validator/request_errors.rb

Overview

Ensure there are no errors in the wrapped contents of the body.

This validator works on responses that have the following format:

<?xml version=“1.0” encoding=“utf-8”?> <soap:Envelope xmlns:soap=“schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“www.w3.org/2001/XMLSchema”>

<soap:Body>
    <GetPropertyResidentsResponse xmlns="http://tempuri.org/">
        <GetPropertyResidentsResult>&lt;InternetTrafficResponse&gt;&lt;webservice&gt;Leasing&lt;/webservice&gt;&lt;webmethod&gt;GetPropertyResidents&lt;/webmethod&gt;&lt;Error&gt;&lt;ErrorCode&gt;1&lt;/ErrorCode&gt;&lt;ErrorDescription&gt;Validation of user credentials failed.&lt;/ErrorDescription&gt;&lt;/Error&gt;&lt;/InternetTrafficResponse&gt;</GetPropertyResidentsResult>
    </GetPropertyResidentsResponse>
</soap:Body>

</soap:Envelope>

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ RequestErrors

Returns a new instance of RequestErrors.

Parameters:

  • response (Hash<String, Object>)

    the XML response parsed into a Hash



21
22
23
# File 'lib/amsi/validator/request_errors.rb', line 21

def initialize(response)
  @response = response
end

Instance Method Details

#validate!Object

Raises:



27
28
29
30
31
# File 'lib/amsi/validator/request_errors.rb', line 27

def validate!
  return unless error?

  raise Amsi::Error::BadRequest, [error]
end