Skip to content

Commit

Permalink
Add C2S EBICS Order type support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Schoknecht committed Jun 3, 2024
1 parent 8fbd8a3 commit 510c3e6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

- [ENHANCEMENT] Adds C2S order tyoe
- [HOUSEKEEPING] updates nokogiri dependency
- [HOUSEKEEPING] updates rexml dependency
- [HOUSEKEEPING] adds Ruby 3.3 to CI
Expand Down
1 change: 1 addition & 0 deletions lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
require "epics/b2b"
require "epics/xds"
require "epics/cds"
require "epics/c2s"
require "epics/cdz"
require "epics/crz"
require "epics/xct"
Expand Down
9 changes: 9 additions & 0 deletions lib/epics/c2s.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Epics::C2S < Epics::CDB
def order_attribute
"DZHNN"
end

def order_type
'C2S'
end
end
12 changes: 10 additions & 2 deletions lib/epics/cdb.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class Epics::CDB < Epics::GenericUploadRequest
def order_attribute
'OZHNN'
end

def order_type
'CDB'
end

def header
Nokogiri::XML::Builder.new do |xml|
xml.header(authenticate: true) {
Expand All @@ -10,8 +18,8 @@ def header
xml.UserID user_id
xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
xml.OrderDetails {
xml.OrderType 'CDB'
xml.OrderAttribute 'OZHNN'
xml.OrderType order_type
xml.OrderAttribute order_attribute
xml.StandardOrderParams
}
xml.BankPubKeyDigests {
Expand Down
4 changes: 4 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def CDB(document)
upload(Epics::CDB, document)
end

def C2S(document)
upload(Epics::C2S, document)
end

def CDD(document)
upload(Epics::CDD, document)
end
Expand Down
21 changes: 21 additions & 0 deletions spec/orders/c2s_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RSpec.describe Epics::C2S 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(:document) { File.read( File.join( File.dirname(__FILE__), '..', 'fixtures', 'xml', 'cdb.xml') ) }
subject { described_class.new(client, document) }

describe 'order attributes' do
it { expect(subject.header.to_s).to include('<OrderAttribute>DZHNN</OrderAttribute>') }
it { expect(subject.header.to_s).to include('<OrderType>C2S</OrderType>') }
end

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
end

describe '#to_transfer_xml' do
before { subject.transaction_id = SecureRandom.hex(16) }

specify { expect(subject.to_transfer_xml).to be_a_valid_ebics_doc }
end
end

0 comments on commit 510c3e6

Please sign in to comment.