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.
205 206 207 208 |
# File 'lib/lookup_service_helper.rb', line 205 def initialize(operation, client) @operation = operation @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
200 201 202 |
# File 'lib/lookup_service_helper.rb', line 200 def client @client end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
200 201 202 |
# File 'lib/lookup_service_helper.rb', line 200 def operation @operation end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
200 201 202 |
# File 'lib/lookup_service_helper.rb', line 200 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.
235 236 237 |
# File 'lib/lookup_service_helper.rb', line 235 def body_xml raise "abstract method not implemented!" end |
#invoke ⇒ Object
Invokes the service call represented by this type.
211 212 213 214 215 216 217 |
# File 'lib/lookup_service_helper.rb', line 211 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.
220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/lookup_service_helper.rb', line 220 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
246 247 248 |
# File 'lib/lookup_service_helper.rb', line 246 def response_hash @response_hash ||= response.to_hash end |
#response_xml ⇒ Object
Gets the response XML content.
240 241 242 243 244 |
# File 'lib/lookup_service_helper.rb', line 240 def response_xml raise "illegal state: response not set yet" if response.nil? @response_xml ||= Nokogiri::XML(response.to_xml) end |