Sha256: 1bd1a605c6839f2f710cf96023886cd8855ee89f69b45f1815e844076dbfe01b

Contents?: true

Size: 886 Bytes

Versions: 6

Compression:

Stored size: 886 Bytes

Contents

require "akami"
require "gyoku"

module Savon
  class Header

    def initialize(globals, locals)
      @globals = globals
      @locals = locals
      @wsse = create_wsse
    end

    def empty?
      to_s.empty?
    end

    def to_s
      return @header if @header

      gyoku_options = { :key_converter => @globals[:convert_request_keys_to] }
      @header = (Hash === header ? Gyoku.xml(header, gyoku_options) : header) + wsse_header
    end

    private

    def create_wsse
      wsse = Akami.wsse
      wsse.credentials(*@globals[:wsse_auth]) if @globals.include? :wsse_auth
      wsse.timestamp = @globals[:wsse_timestamp] if @globals.include? :wsse_timestamp
      wsse
    end

    def header
      @header ||= @globals.include?(:soap_header) ? @globals[:soap_header] : {}
    end

    def wsse_header
      @wsse.respond_to?(:to_xml) ? @wsse.to_xml : ""
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
savon-2.2.0 lib/savon/header.rb
savon-2.1.0 lib/savon/header.rb
savon-2.0.3 lib/savon/header.rb
savon-2.0.2 lib/savon/header.rb
savon-2.0.1 lib/savon/header.rb
savon-2.0.0 lib/savon/header.rb