Class: Inforouter::Responses::Base
- Inherits:
-
Object
- Object
- Inforouter::Responses::Base
- Defined in:
- lib/inforouter/responses/base.rb
Overview
A base infoRouter SOAP response.
Instance Attribute Summary collapse
-
#raw ⇒ Object
Raw response.
Class Method Summary collapse
-
.error_message(value) ⇒ Object
Location of the error message in the SOAP XML.
-
.parse(savon_response) ⇒ Object
Parse a SOAP response.
- .parse_datetime(date) ⇒ DateTime
-
.response_success(value) ⇒ Object
Location of the response in the SOAP XML.
- .set_dsl(key, value) ⇒ Object
Instance Method Summary collapse
-
#initialize(savon_response) ⇒ Base
constructor
A new instance of Base.
-
#match(chain) ⇒ Object
Match an element in the SOAP response.
Constructor Details
#initialize(savon_response) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/inforouter/responses/base.rb', line 9 def initialize(savon_response) @raw = savon_response.to_hash parse! end |
Instance Attribute Details
#raw ⇒ Object
Raw response.
6 7 8 |
# File 'lib/inforouter/responses/base.rb', line 6 def raw @raw end |
Class Method Details
.error_message(value) ⇒ Object
Location of the error message in the SOAP XML.
21 22 23 |
# File 'lib/inforouter/responses/base.rb', line 21 def (value) set_dsl(:error_message, value) end |
.parse(savon_response) ⇒ Object
Parse a SOAP response.
28 29 30 |
# File 'lib/inforouter/responses/base.rb', line 28 def parse(savon_response) new(savon_response) end |
.parse_datetime(date) ⇒ DateTime
60 61 62 63 64 |
# File 'lib/inforouter/responses/base.rb', line 60 def parse_datetime(date) DateTime.strptime("#{date} #{DateTime.now.zone}", "%Y-%m-%d %H:%M:%S %Z") rescue ArgumentError nil end |
.response_success(value) ⇒ Object
Location of the response in the SOAP XML.
16 17 18 |
# File 'lib/inforouter/responses/base.rb', line 16 def response_success(value) set_dsl(:response_success, value) end |
.set_dsl(key, value) ⇒ Object
51 52 53 54 55 |
# File 'lib/inforouter/responses/base.rb', line 51 def set_dsl(key, value) self.dsl ||= {} self.dsl[key] = value self.dsl end |
Instance Method Details
#match(chain) ⇒ Object
Match an element in the SOAP response
36 37 38 39 40 41 42 43 44 |
# File 'lib/inforouter/responses/base.rb', line 36 def match(chain) current_value = raw chain.split('/').each do |key| current_value = current_value[key.to_sym] next if current_value fail Inforouter::Errors::UnexpectedSOAPResponse.new(raw, key, chain) end current_value end |