From b0a25f1e81376a06cdb937cc5cd6538ab8aaea66 Mon Sep 17 00:00:00 2001 From: Tobias Schoknecht Date: Mon, 3 Jun 2024 18:29:25 +0200 Subject: [PATCH 1/2] Update nokogiri and rexml gem dependencies again --- epics.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epics.gemspec b/epics.gemspec index b8a7b03..8fd1a2a 100644 --- a/epics.gemspec +++ b/epics.gemspec @@ -41,9 +41,9 @@ Gem::Specification.new do |spec| spec.post_install_message += "\e[32m" + ('*' * 60) + "\n\e[0m" spec.add_dependency 'faraday', '>= 1.10.0' - spec.add_dependency 'nokogiri', '>= 1.16.0' + spec.add_dependency 'nokogiri', '>= 1.16.5' spec.add_dependency 'rubyzip', '>= 2.3.2' - spec.add_dependency 'rexml', '>= 3.2.6' + spec.add_dependency 'rexml', '>= 3.2.8' spec.add_development_dependency 'bundler', '>= 2.4.12' spec.add_development_dependency 'equivalent-xml' From c4d445e4dbaa08438d4296518e8ca600dd84e21f Mon Sep 17 00:00:00 2001 From: Tobias Schoknecht Date: Mon, 3 Jun 2024 18:29:48 +0200 Subject: [PATCH 2/2] Add C2S EBICS Order type support --- CHANGELOG.md | 1 + lib/epics.rb | 1 + lib/epics/c2s.rb | 9 +++++++++ lib/epics/cdb.rb | 12 ++++++++++-- lib/epics/client.rb | 4 ++++ spec/orders/c2s_spec.rb | 21 +++++++++++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 lib/epics/c2s.rb create mode 100644 spec/orders/c2s_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 66fe368..5984231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/epics.rb b/lib/epics.rb index 39919b8..a27a13c 100644 --- a/lib/epics.rb +++ b/lib/epics.rb @@ -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" diff --git a/lib/epics/c2s.rb b/lib/epics/c2s.rb new file mode 100644 index 0000000..88a38d6 --- /dev/null +++ b/lib/epics/c2s.rb @@ -0,0 +1,9 @@ +class Epics::C2S < Epics::CDB + def order_attribute + "DZHNN" + end + + def order_type + 'C2S' + end +end diff --git a/lib/epics/cdb.rb b/lib/epics/cdb.rb index 45f2552..c004f24 100644 --- a/lib/epics/cdb.rb +++ b/lib/epics/cdb.rb @@ -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) { @@ -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 { diff --git a/lib/epics/client.rb b/lib/epics/client.rb index 62104c6..9fa6f59 100644 --- a/lib/epics/client.rb +++ b/lib/epics/client.rb @@ -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 diff --git a/spec/orders/c2s_spec.rb b/spec/orders/c2s_spec.rb new file mode 100644 index 0000000..fba7b21 --- /dev/null +++ b/spec/orders/c2s_spec.rb @@ -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('DZHNN') } + it { expect(subject.header.to_s).to include('C2S') } + 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