Class: Exchanger::Operation::Response
- Inherits:
-
Object
- Object
- Exchanger::Operation::Response
- Defined in:
- lib/exchanger/operation.rb
Direct Known Subclasses
CreateAttachment::Response, CreateItem::Response, DeleteAttachment::Response, DeleteItem::Response, ExpandDL::Response, FindFolder::Response, FindItem::Response, GetAttachment::Response, GetFolder::Response, GetItem::Response, GetUserAvailability::Response, GetUserConfiguration::Response, MoveItem::Response, ResolveNames::Response, UpdateItem::Response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(options = {}) ⇒ Response
constructor
A new instance of Response.
-
#parse_response_message ⇒ Object
Checks the ResponseMessage for errors.
- #parse_soap_errors ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Response
Returns a new instance of Response.
73 74 75 76 77 78 |
# File 'lib/exchanger/operation.rb', line 73 def initialize( = {}) @status = [:status] @body = [:body] parse_soap_errors end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
71 72 73 |
# File 'lib/exchanger/operation.rb', line 71 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
71 72 73 |
# File 'lib/exchanger/operation.rb', line 71 def status @status end |
Instance Method Details
#code ⇒ Object
105 106 107 |
# File 'lib/exchanger/operation.rb', line 105 def code raise NotImplemented end |
#parse_response_message ⇒ Object
Checks the ResponseMessage for errors.
msdn.microsoft.com/en-us/library/aa494164%28EXCHG.80%29.aspx Exhange 2007 Valid Response Messages
96 97 98 99 100 101 102 103 |
# File 'lib/exchanger/operation.rb', line 96 def error_node = to_xml.xpath('//m:ResponseMessages/child::*[@ResponseClass="Error"]', NS) unless error_node.empty? error_msg = error_node.xpath('m:MessageText/text()', NS).to_s response_code = error_node.xpath('m:ResponseCode/text()', NS).to_s raise ResponseError.new(error_msg, response_code) end end |
#parse_soap_errors ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/exchanger/operation.rb', line 84 def parse_soap_errors fault_node = to_xml.xpath(".//faultstring") unless fault_node.empty? error_msg = fault_node.text raise ResponseError.new(error_msg, 0) end end |
#to_xml ⇒ Object
80 81 82 |
# File 'lib/exchanger/operation.rb', line 80 def to_xml @xml ||= Nokogiri::XML(@body) end |