Class: Soap::Webservice::Response
- Inherits:
-
Object
- Object
- Soap::Webservice::Response
- Defined in:
- lib/soap/webservice/response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #decoded_body ⇒ Object
- #header ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #to_xml ⇒ Object
-
#validate_body_attrs! ⇒ Object
rubocop:enable all.
-
#validate_errors! ⇒ Object
rubocop:disable all.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
16 17 18 19 20 21 22 |
# File 'lib/soap/webservice/response.rb', line 16 def initialize(response) @response = response @errors = [] validate_errors! validate_body_attrs! end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
14 15 16 |
# File 'lib/soap/webservice/response.rb', line 14 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/soap/webservice/response.rb', line 13 def response @response end |
Class Method Details
.body_attributes ⇒ Object
10 |
# File 'lib/soap/webservice/response.rb', line 10 def body_attributes; {} end |
.header_attributes ⇒ Object
8 |
# File 'lib/soap/webservice/response.rb', line 8 def header_attributes; {} end |
Instance Method Details
#body ⇒ Object
52 53 54 |
# File 'lib/soap/webservice/response.rb', line 52 def body response.body end |
#decoded_body ⇒ Object
56 57 58 |
# File 'lib/soap/webservice/response.rb', line 56 def decoded_body response.body end |
#header ⇒ Object
48 49 50 |
# File 'lib/soap/webservice/response.rb', line 48 def header response.header end |
#to_xml ⇒ Object
60 61 62 |
# File 'lib/soap/webservice/response.rb', line 60 def to_xml response.to_xml end |
#validate_body_attrs! ⇒ Object
rubocop:enable all
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/soap/webservice/response.rb', line 37 def validate_body_attrs! return if required_body.empty? if !required_body.empty? && attributes.empty? raise "Required attributes are missing #{required_body}" end if !(required_body - attributes.keys).empty? raise "Attribute #{required_body - attributes.keys} must be present" end end |
#validate_errors! ⇒ Object
rubocop:disable all
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/soap/webservice/response.rb', line 25 def validate_errors! case response.http.code when 200 errors << Soap::Webservice::FaultError.new(response) when 500 errors << Soap::Webservice::Error.new(response) else errors << Soap::Webservice::GenericError.new(response) end end |