Class: Invocable Abstract
- Inherits:
-
Object
- Object
- Invocable
- Defined in:
- lib/lookup_service_helper.rb
Overview
This class is abstract.
Base class for invocable service calls.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#body_xml ⇒ Object
Builds the body portion of the request XML content.
-
#initialize(operation, client) ⇒ Invocable
constructor
Constructs a new instance.
-
#invoke ⇒ Object
Invokes the service call represented by this type.
-
#request_xml ⇒ Object
Builds the request XML content.
- #response_hash ⇒ Object
-
#response_xml ⇒ Object
Gets the response XML content.
Constructor Details
#initialize(operation, client) ⇒ Invocable
Constructs a new instance.
204 205 206 207 |
# File 'lib/lookup_service_helper.rb', line 204 def initialize(operation, client) @operation = operation @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
199 200 201 |
# File 'lib/lookup_service_helper.rb', line 199 def client @client end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
199 200 201 |
# File 'lib/lookup_service_helper.rb', line 199 def operation @operation end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
199 200 201 |
# File 'lib/lookup_service_helper.rb', line 199 def response @response end |
Instance Method Details
#body_xml ⇒ Object
Builds the body portion of the request XML content. Specific service operations must override this method.
234 235 236 |
# File 'lib/lookup_service_helper.rb', line 234 def body_xml raise 'abstract method not implemented!' end |
#invoke ⇒ Object
Invokes the service call represented by this type.
210 211 212 213 214 215 216 |
# File 'lib/lookup_service_helper.rb', line 210 def invoke request = request_xml.to_s Base.log.debug(request) @response = client.call(operation, xml:request) Base.log.debug(response) self # for chaining with new end |
#request_xml ⇒ Object
Builds the request XML content.
219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/lookup_service_helper.rb', line 219 def request_xml builder = Builder::XmlMarkup.new() builder.instruct!(:xml, encoding: "UTF-8") builder.tag!("S:Envelope", "xmlns:S" => "http://schemas.xmlsoap.org/soap/envelope/") do |envelope| envelope.tag!("S:Body") do |body| body_xml(body) end end builder.target! end |
#response_hash ⇒ Object
244 245 246 |
# File 'lib/lookup_service_helper.rb', line 244 def response_hash @response_hash ||= response.to_hash end |
#response_xml ⇒ Object
Gets the response XML content.
239 240 241 242 |
# File 'lib/lookup_service_helper.rb', line 239 def response_xml raise 'illegal state: response not set yet' if response.nil? @response_xml ||= Nokogiri::XML(response.to_xml) end |