Class: Epics::INI

Inherits:
GenericRequest show all
Defined in:
lib/epics/ini.rb

Instance Attribute Summary

Attributes inherited from GenericRequest

#client, #options, #transaction_id

Instance Method Summary collapse

Methods inherited from GenericRequest

#auth_signature, #initialize, #nonce, #timestamp, #to_receipt_xml, #to_transfer_xml

Constructor Details

This class inherits a constructor from Epics::GenericRequest

Instance Method Details

#body ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/epics/ini.rb', line 15

def body
  Nokogiri::XML::Builder.new do |xml|
    xml.body{
      xml.DataTransfer {
        xml.OrderData Base64.strict_encode64(Zlib::Deflate.deflate(key_signature))
      }
    }
  end.doc.root
end

#header ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/epics/ini.rb', line 6

def header
  client.header_request.build(
    order_type: 'INI',
    order_attribute: 'DZNNN',
    with_bank_pubkey_digests: false,
    mutable: {},
  )
end

#key_signature ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/epics/ini.rb', line 25

def key_signature
  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 {
        x509_data_xml(xml, client.x_509_certificate(:a))
        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

#root ⇒ Object



2
3
4
# File 'lib/epics/ini.rb', line 2

def root
  "ebicsUnsecuredRequest"
end

#to_xml ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/epics/ini.rb', line 45

def to_xml
  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)
    }
  end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
end