Sha256: 80feca8786d2a2d77a73c93bacd29014b924250fdcccdf3c9a75de5e4d4b9df2

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module NNEClient
  # @!visibility private
  class Request
    class << self
      def execute(command, &block)
        new(command).result_set(&block)
      end
    end

    def initialize(command)
      @command = command
    end

    def result_set(&block)
      ResultSet.new(perform_request(&block))
    end

    private

    def perform_request(&block)
      client.request('wsdl', @command, request_attributes) do
        if false
          # Savon 0.9.5 does not support this
          soap.body do |xml|
            yield xml
          end
        else
          # So create a builder manually
          str = StringIO.new
          builder = Builder::XmlMarkup.new(:target => str)
          yield builder
          str.rewind
          soap.body = str.read
        end
      end
    end

    def request_attributes
      { "env:encodingStyle" => "http://schemas.xmlsoap.org/soap/encoding/" }
    end

    def client
      @client ||= Savon::Client.new do
        wsdl.document = File.expand_path("../../../wsdl/nne.wsdl", __FILE__)
      end
      @client.http.read_timeout = NNEClient.config.http_read_timeout
      @client
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nne_client-0.0.7 lib/nne_client/request.rb
nne_client-0.0.6 lib/nne_client/request.rb