Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fdl message #80

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions lib/epics/fdl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class Epics::FDL < Epics::GenericRequest
attr_accessor :file_format

def initialize(client, file_format)
super(client)
self.file_format = file_format
end


def header
builder = 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
xml_string = builder.to_xml
File.open('/tmp/file.xml', 'w') do |file|
gstenson marked this conversation as resolved.
Show resolved Hide resolved
# write the xml string generated above to the file
file.write xml_string
end
builder.doc.root
end
end
24 changes: 24 additions & 0 deletions spec/orders/fdl_spec.rb
Original file line number Diff line number Diff line change
@@ -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('<FDLOrderParams><FileFormat>camt.fin.mt940.stm.0w1</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