Sha256: a3b2451bb184aea49dd5f1a1a1fc94cda02459baf5bb0bebab3794e04f37133a

Contents?: true

Size: 706 Bytes

Versions: 3

Compression:

Stored size: 706 Bytes

Contents

require 'builder'

module Arbetsformedlingen
  class SOAPBuilder
    SOAP_ATTRIBUTES = {
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
      'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
      'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'
    }.freeze

    def self.wrap(&block)
      new.wrap(&block)
    end

    def initialize
      @builder = Builder::XmlMarkup.new(indent: 2)
      @builder.instruct!

      yield self if block_given?
    end

    def wrap
      @builder.soap12(:Envelope, SOAP_ATTRIBUTES) do |envelope|
        envelope.soap12(:Body) { |body| yield(body) }
      end

      self
    end

    def to_xml
      @builder.target!
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arbetsformedlingen-0.5.0 lib/arbetsformedlingen/soap_builder.rb
arbetsformedlingen-0.4.1 lib/arbetsformedlingen/soap_builder.rb
arbetsformedlingen-0.4.0 lib/arbetsformedlingen/soap_builder.rb