Class: Invocable Abstract

Inherits:
Object
  • Object
show all
Defined in:
/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb

Overview

This class is abstract.

Base class for invocable service calls.

Direct Known Subclasses

List, RetrieveServiceContent

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Invocable) initialize(operation, client)

Constructs a new instance.

Parameters:

  • operation (Symbol)

    the operation name

  • client (Savon::Client)

    the client



214
215
216
217
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 214

def initialize(operation, client)
    @operation = operation
    @client = client
end

Instance Attribute Details

- (Object) client (readonly)

Returns the value of attribute client



209
210
211
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 209

def client
  @client
end

- (Object) operation (readonly)

Returns the value of attribute operation



209
210
211
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 209

def operation
  @operation
end

- (Object) response (readonly)

Returns the value of attribute response



209
210
211
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 209

def response
  @response
end

Instance Method Details

- (Object) body_xml

Builds the body portion of the request XML content. Specific service operations must override this method.



244
245
246
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 244

def body_xml
    raise 'abstract method not implemented!'
end

- (Object) invoke

Invokes the service call represented by this type.



220
221
222
223
224
225
226
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 220

def invoke
    request = request_xml.to_s
    Sample.log.debug(request)
    @response = client.call(operation, xml:request)
    Sample.log.debug(response)
    self # for chaining with new
end

- (Object) request_xml

Builds the request XML content.



229
230
231
232
233
234
235
236
237
238
239
240
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 229

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

- (Object) response_hash



254
255
256
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 254

def response_hash
    @response_hash ||= response.to_hash
end

- (Object) response_xml

Gets the response XML content.



249
250
251
252
# File '/build/mts/release/bora-4571906/vcsuite-sdks/ruby/samples/lib/sample/framework/lookup_service_helper.rb', line 249

def response_xml
    raise 'illegal state: response not set yet' if response.nil?
    @response_xml ||= Nokogiri::XML(response.to_xml)
end