diff --git a/.gitignore b/.gitignore index 251dd8a..3aaba57 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ mkmf.log .DS_Store sbk.key /mt940 -*.key \ No newline at end of file +*.key +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 387d95b..da94266 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It supports EBICS 2.5. The client supports the complete initialization process comprising INI, HIA and HPB including the INI letter generation. It offers support for the most common download and upload order types -(STA HAA HTD HPD PTK HAC HKD C52 C53 C54 CD1 CDB CDD CCT VMK). +(STA HAA HTD HPD PTK HAC HKD C52 C53 C54 CD1 CDB CDD CCT VMK FDL). ## Installation @@ -222,6 +222,7 @@ Used for example by the following tested institutions: - Hypo Vereinsbank - BAWAG P.S.K. (AT) - Bank Frick (LI) +- BNP Paribas (FR) 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 835700b..54d8788 100644 --- a/lib/epics.rb +++ b/lib/epics.rb @@ -25,6 +25,7 @@ require "epics/htd" require "epics/haa" require "epics/sta" +require "epics/fdl" require "epics/vmk" require "epics/c52" require "epics/c53" diff --git a/lib/epics/client.rb b/lib/epics/client.rb index b0b3e10..f2c6a53 100644 --- a/lib/epics/client.rb +++ b/lib/epics/client.rb @@ -182,6 +182,10 @@ def STA(from = nil, to = nil) download(Epics::STA, from: from, to: to) end + def FDL(format) + download(Epics::FDL, file_format: format) + end + def VMK(from = nil, to = nil) download(Epics::VMK, from: from, to: to) end diff --git a/lib/epics/fdl.rb b/lib/epics/fdl.rb new file mode 100644 index 0000000..b1bef17 --- /dev/null +++ b/lib/epics/fdl.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class Epics::FDL < Epics::GenericRequest + def header + client.header_request.build( + nonce: nonce, + timestamp: timestamp, + order_type: 'FDL', + order_attribute: 'DZHNN', + order_id: 'A00A', + custom_order_params: { FDLOrderParams: { FileFormat: options[:file_format] } }, + mutable: { TransactionPhase: 'Initialisation' } + ) + end +end diff --git a/lib/epics/header_request.rb b/lib/epics/header_request.rb index de18006..2754c01 100644 --- a/lib/epics/header_request.rb +++ b/lib/epics/header_request.rb @@ -29,6 +29,7 @@ def build(options = {}) xml.StandardOrderParams { build_attributes(xml, options[:order_params]) } if options[:order_params] + build_attributes(xml, options[:custom_order_params]) if options[:custom_order_params] } xml.BankPubKeyDigests { xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256') diff --git a/spec/orders/fdl_spec.rb b/spec/orders/fdl_spec.rb new file mode 100644 index 0000000..628c1ac --- /dev/null +++ b/spec/orders/fdl_spec.rb @@ -0,0 +1,40 @@ +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') } + let(:file_format) { 'camt.xxx.cfonb120.stm.Oby' } + + context 'with file_format' do + subject(:order) { described_class.new(client, file_format: file_format) } + + describe '#to_xml' do + specify { expect(order.to_xml).to be_a_valid_ebics_doc } + + it 'does includes a date range as standard order parameter' do + expect(order.to_xml).to include('camt.xxx.cfonb120.stm.Oby') + 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 + + context 'without file_format' do + subject(:order) { described_class.new(client) } + + describe '#to_xml' do + specify { expect(order.to_xml).to be_a_valid_ebics_doc } + + it 'does not include a standard order parameter' do + expect(order.to_xml).to include('') + 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