lib/epics/ini.rb in epics-1.5.1 vs lib/epics/ini.rb in epics-1.5.2

- old
+ new

@@ -1,69 +1,62 @@ class Epics::INI < Epics::GenericRequest - def root "ebicsUnsecuredRequest" end def header - { - :@authenticate => true, - static: { - "HostID" => host_id, - "PartnerID" => partner_id, - "UserID" => user_id, - "Product" => { - :@Language => "de", - :content! => "EPICS - a ruby ebics kernel" - }, - "OrderDetails" => { - "OrderType" => "INI", - "OrderAttribute" => "DZNNN" - }, - "SecurityMedium" => "0000" - }, - "mutable" => "" - } + Nokogiri::XML::Builder.new do |xml| + xml.header(authenticate: true) { + xml.static { + xml.HostID host_id + xml.PartnerID partner_id + xml.UserID user_id + xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de') + xml.OrderDetails { + xml.OrderType 'INI' + xml.OrderAttribute 'DZNNN' + } + xml.SecurityMedium '0000' + } + xml.mutable '' + } + end.doc.root end def body - { - "DataTransfer" => { - "OrderData" => Base64.strict_encode64(Zlib::Deflate.deflate(key_signature)) + Nokogiri::XML::Builder.new do |xml| + xml.body{ + xml.DataTransfer { + xml.OrderData Base64.strict_encode64(Zlib::Deflate.deflate(key_signature)) + } } - } + end.doc.root end def key_signature - "<?xml version='1.0' encoding='utf-8'?>\n"+ - Gyoku.xml("SignaturePubKeyOrderData" => { - :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#", - :"@xmlns" => "http://www.ebics.org/S001", - "SignaturePubKeyInfo" => { - "PubKeyValue" => { - "ds:RSAKeyValue" => { - "ds:Modulus" => Base64.strict_encode64([client.a.n].pack("H*")), - "ds:Exponent" => Base64.strict_encode64(client.a.key.e.to_s(2)) - }, - "TimeStamp" => timestamp - }, - "SignatureVersion" => "A006" - }, - "PartnerID" => partner_id, - "UserID" => user_id - }) + Nokogiri::XML::Builder.new do |xml| + xml.SignaturePubKeyOrderData('xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'http://www.ebics.org/S001') { + xml.SignaturePubKeyInfo { + xml.PubKeyValue { + xml.send('ds:RSAKeyValue') { + xml.send('ds:Modulus', Base64.strict_encode64([client.a.n].pack("H*"))) + xml.send('ds:Exponent', Base64.strict_encode64(client.a.key.e.to_s(2))) + } + xml.TimeStamp timestamp + } + xml.SignatureVersion 'A006' + } + xml.PartnerID partner_id + xml.UserID user_id + } + end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8') end def to_xml - Nokogiri::XML.parse(Gyoku.xml( { - root => { - :"@xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#", - :@xmlns => "urn:org:ebics:H004", - :@Version => "H004", - :@Revision => "1", - :header => header, - "body" => body + Nokogiri::XML::Builder.new do |xml| + xml.send(root, 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'urn:org:ebics:H004', 'Version' => 'H004', 'Revision' => '1') { + xml.parent.add_child(header) + xml.parent.add_child(body) } - }), nil, "utf-8").to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML) + end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8') end - end