module Ragoon::XML
ACTION_PLACEHOLDER = ''.freeze
BODY_PLACEHOLDER = ''.freeze
def self.render(action_name, body_node, options)
template(options).dup.
gsub!(ACTION_PLACEHOLDER, action_name).
gsub!(BODY_PLACEHOLDER, body_node.to_xml)
end
def self.create_node(name, attributes = {})
node = Nokogiri::XML::Node.new(name, Nokogiri::XML.parse(''))
attributes.each do |key, value|
node[key.to_s] = value
end
node
end
def self.template(options)
<<"XML"
#{ACTION_PLACEHOLDER}
#{options[:username]}
#{options[:password]}
#{Time.now.iso8601}
#{(Time.now + 60 * 60 * 24).iso8601}
jp
#{BODY_PLACEHOLDER}
XML
end
end