module Ragoon::XML
ACTION_PLACEHOLDER = ''.freeze
BODY_PLACEHOLDER = ''.freeze
def self.render(action_name, body_node)
template.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
<<"XML"
#{ACTION_PLACEHOLDER}
#{Ragoon.garoon_username}
#{Ragoon.garoon_password}
#{Time.now.iso8601}
#{(Time.now + 60 * 60 * 24).iso8601}
jp
#{BODY_PLACEHOLDER}
XML
end
end