Skip to content

Commit

Permalink
add FDL order and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
frantisekrokusek committed Dec 16, 2024
1 parent d0aa075 commit 780067a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ mkmf.log
.DS_Store
sbk.key
/mt940
*.key
*.key
.idea/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions lib/epics/fdl.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/epics/header_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
40 changes: 40 additions & 0 deletions spec/orders/fdl_spec.rb
Original file line number Diff line number Diff line change
@@ -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('<FDLOrderParams><FileFormat>camt.xxx.cfonb120.stm.Oby</FileFormat></FDLOrderParams>')
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('<FDLOrderParams><FileFormat/></FDLOrderParams>')
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

0 comments on commit 780067a

Please sign in to comment.