diff --git a/README.md b/README.md index 8531355..4838f48 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ Used for example by the following tested institutions: - Hypo Vereinsbank - BAWAG P.S.K. (AT) - Bank Frick (LI) +- BNP (FDL order type only) Is Epics working with your institution? Please help us to grow this list of supported banks: diff --git a/lib/epics.rb b/lib/epics.rb index 08a88a7..fc3c5aa 100644 --- a/lib/epics.rb +++ b/lib/epics.rb @@ -29,6 +29,7 @@ require "epics/c54" require "epics/ptk" require "epics/hac" +require "epics/fdl" require "epics/hpd" require "epics/cd1" require "epics/cct" diff --git a/lib/epics/client.rb b/lib/epics/client.rb index de502e2..9e190d3 100644 --- a/lib/epics/client.rb +++ b/lib/epics/client.rb @@ -163,6 +163,10 @@ def STA(from = nil, to = nil) download(Epics::STA, from, to) end + def FDL(format) + download(Epics::FDL, format) + end + def VMK(from = nil, to = nil) download(Epics::VMK, from, to) end diff --git a/lib/epics/fdl.rb b/lib/epics/fdl.rb new file mode 100644 index 0000000..1bbd589 --- /dev/null +++ b/lib/epics/fdl.rb @@ -0,0 +1,40 @@ +class Epics::FDL < Epics::GenericRequest + attr_accessor :file_format + + def initialize(client, file_format) + super(client) + self.file_format = file_format + end + + + def header + Nokogiri::XML::Builder.new do |xml| + xml.header(authenticate: true) { + xml.static { + xml.HostID host_id + xml.Nonce nonce + xml.Timestamp timestamp + xml.PartnerID partner_id + xml.UserID user_id + xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de') + xml.OrderDetails { + xml.OrderType 'FDL' + xml.OrderID "A00A" + xml.OrderAttribute "DZHNN" + xml.FDLOrderParams { + xml.FileFormat file_format + } + } + xml.BankPubKeyDigests { + xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256") + xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" ) + } + xml.SecurityMedium "0000" + } + xml.mutable { + xml.TransactionPhase 'Initialisation' + } + } + end.doc.root + end +end diff --git a/spec/orders/fdl_spec.rb b/spec/orders/fdl_spec.rb new file mode 100644 index 0000000..3c5d8cc --- /dev/null +++ b/spec/orders/fdl_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe Epics::FDL do + let(:client) { Epics::Client.new( File.open(File.join( File.dirname(__FILE__), '..', 'fixtures', 'SIZBN001.key')), 'secret' , 'https://194.180.18.30/ebicsweb/ebicsweb', 'SIZBN001', 'EBIX', 'EBICS') } + + context 'with file format' do + subject(:order) { described_class.new(client, "camt.fin.mt940.stm.0w1") } + + describe '#to_xml' do + specify { expect(order.to_xml).to be_a_valid_ebics_doc } + + it 'does includes a file format as standard order parameter' do + + expect(order.to_xml).to include('camt.fin.mt940.stm.0w1') + end + end + + describe '#to_receipt_xml' do + before { order.transaction_id = SecureRandom.hex(16) } + + specify { expect(order.to_receipt_xml).to be_a_valid_ebics_doc } + end + end + + +end