class Stellae::Request

Constants

SCHEMA

Public Class Methods

new(client) click to toggle source
# File lib/stellae/request.rb, line 13
def initialize(client)
  @client = client
end

Public Instance Methods

build_header(xml, action) click to toggle source
# File lib/stellae/request.rb, line 32
def build_header(xml, action)
  xml.s :Header do
    xml.a :Action,    "SII/ISIIService/#{action}", :"s:mustUnderstand" => "1"
    xml.a :MessageID, "urn:uuid:56b55a70-8bbc-471d-94bb-9ca060bcf99f"
    xml.a :ReplyTo do
      xml.a :Address, "http://www.w3.org/2005/08/addressing/anonymous"
    end
    xml.a :To, @client.request_uri.split('?').first, :"s:mustUnderstand" => "1"
  end
end
build_user(xml) click to toggle source
# File lib/stellae/request.rb, line 43
def build_user(xml)
  xml.user :"xmlns:a" => SCHEMA[:datacontract], :"xmlns:i" => SCHEMA[:instance] do
    soap_field xml, :user_name,     @client.username
    soap_field xml, :user_password, @client.password
  end
end
construct_xml(type) { |xml| ... } click to toggle source
# File lib/stellae/request.rb, line 17
def construct_xml(type)
  @client.type = type
  xml = Builder::XmlMarkup.new
  xml.s :Envelope, :"xmlns:s" => SCHEMA[:soap_envelop], :"xmlns:a" => SCHEMA[:addressing] do
    build_header(xml, type)
    xml.s :Body do 
      xml.tag! type, :"xmlns" => "SII" do          
        build_user xml
        yield(xml)
      end
    end
  end
  xml.target!
end
soap_field(xml, field, value = nil, prefix = "a") { |xml| ... } click to toggle source
# File lib/stellae/request.rb, line 50
def soap_field(xml, field, value = nil, prefix = "a")
  if block_given?
    xml.tag! prefix, field.to_sym do
      yield(xml)
    end
  else
    xml.tag! prefix, field.to_sym, soap_value(value)
  end
end
soap_value(value) click to toggle source
# File lib/stellae/request.rb, line 60
def soap_value(value)
  value.presence || { :"i:nil" => "true" }
end