Class: XmlPayload::XmlGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/valuefirst/xml_payload/xml_generator.rb

Class Method Summary collapse

Class Method Details

.add_attributes(node, attributes) ⇒ Object



10
11
12
13
14
# File 'lib/valuefirst/xml_payload/xml_generator.rb', line 10

def self.add_attributes( node, attributes )
  attributes.each do |name, value|
    XML::Attr.new( node, name, value )
  end
end

.create_node(name, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/valuefirst/xml_payload/xml_generator.rb', line 16

def self.create_node( name, options = {} )
  node = XML::Node.new( name )
  
  attributes = options.delete( :attributes ) unless options.empty?
  add_attributes( node, attributes ) if attributes
  
  node
end

.new_docObject



4
5
6
7
8
# File 'lib/valuefirst/xml_payload/xml_generator.rb', line 4

def self.new_doc
  doc = XML::Document.new
  doc.encoding = XML::Encoding::ISO_8859_1
  doc
end

.user_tag(vfirst_config) ⇒ Object



25
26
27
# File 'lib/valuefirst/xml_payload/xml_generator.rb', line 25

def self.user_tag vfirst_config
  XmlPayload::XmlGenerator.create_node("USER", attributes: {"USERNAME" => vfirst_config.username.to_s, "PASSWORD" => vfirst_config.password.to_s})
end