From df67b5f0cc8d148a3a599940fb57276bb5789bdb Mon Sep 17 00:00:00 2001 From: Tobias Schoknecht Date: Wed, 27 Nov 2024 19:52:51 +0100 Subject: [PATCH] Add CIP order type --- CHANGELOG.md | 1 + lib/epics.rb | 1 + lib/epics/cip.rb | 13 +++++ lib/epics/client.rb | 4 ++ spec/client_spec.rb | 2 +- spec/fixtures/xml/cip.xml | 86 ++++++++++++++++++++++++++++ spec/fixtures/xml/htd_order_data.xml | 8 ++- spec/orders/cip_spec.rb | 23 ++++++++ 8 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 lib/epics/cip.rb create mode 100644 spec/fixtures/xml/cip.xml create mode 100644 spec/orders/cip_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 832c4f5..150a6d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### Unreleased +- [ENHANCEMENT] Adds CIP order type (instant transfers) - [ENHANCEMENT] Added gem metadata (thanks to @Nymuxyzo) ### 2.5.0 diff --git a/lib/epics.rb b/lib/epics.rb index 676919b..835700b 100644 --- a/lib/epics.rb +++ b/lib/epics.rb @@ -40,6 +40,7 @@ require "epics/cd1" require "epics/cct" require "epics/ccs" +require "epics/cip" require "epics/cdb" require "epics/cdd" require "epics/xe2" diff --git a/lib/epics/cip.rb b/lib/epics/cip.rb new file mode 100644 index 0000000..1879b60 --- /dev/null +++ b/lib/epics/cip.rb @@ -0,0 +1,13 @@ +class Epics::CIP < Epics::GenericUploadRequest + def header + client.header_request.build( + nonce: nonce, + timestamp: timestamp, + order_type: 'CIP', + order_attribute: 'OZHNN', + order_params: {}, + num_segments: 1, + mutable: { TransactionPhase: 'Initialisation' } + ) + end +end diff --git a/lib/epics/client.rb b/lib/epics/client.rb index 22bf6b3..b0b3e10 100644 --- a/lib/epics/client.rb +++ b/lib/epics/client.rb @@ -166,6 +166,10 @@ def CCT(document) upload(Epics::CCT, document) end + def CIP(document) + upload(Epics::CIP, document) + end + def CCS(document) upload(Epics::CCS, document) end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 23515bb..9b6900b 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -88,7 +88,7 @@ end it 'extracts the accessible order types of a subscriber' do - expect(subject.order_types).to match_array(%w(PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDB CDD)) + expect(subject.order_types).to match_array(%w(PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CIP CD1 CDB CDD)) end end diff --git a/spec/fixtures/xml/cip.xml b/spec/fixtures/xml/cip.xml new file mode 100644 index 0000000..ab7ef00 --- /dev/null +++ b/spec/fixtures/xml/cip.xml @@ -0,0 +1,86 @@ + + + + + Message-ID-0815 + 2022-09-15T09:31:39.000Z + 2 + 1122.33 + + Initiator Name + + + + Payment-Information-ID-0815 + TRF + true + 2 + 1122.33 + + + SEPA + + + INST + + + + 2022-09-16T10:00:00 + + + Herr Schnellzahler + + + + DE89370400440532013000 + + + + + + NOTPROVIDED + + + + SLEV + + + OriginID1 + + + 1022.00 + + + John Dough + + + + AT611904300234573201 + + + + Unstructured Remittance Information + + + + + OriginID2 + + + 100.33 + + + Cookie Cutter + + + + AT611904300234573201 + + + + Unstructured Remittance Information + + + + + diff --git a/spec/fixtures/xml/htd_order_data.xml b/spec/fixtures/xml/htd_order_data.xml index 53697af..99019f9 100644 --- a/spec/fixtures/xml/htd_order_data.xml +++ b/spec/fixtures/xml/htd_order_data.xml @@ -127,6 +127,12 @@ Credit Transfer Initiation 1 + + CIP + Upload + Instant Credit Transfer Initiation + 1 + CD1 Upload @@ -153,7 +159,7 @@ PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ - INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDB CDD + INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CIP CD1 CDB CDD diff --git a/spec/orders/cip_spec.rb b/spec/orders/cip_spec.rb new file mode 100644 index 0000000..9415fe3 --- /dev/null +++ b/spec/orders/cip_spec.rb @@ -0,0 +1,23 @@ +RSpec.describe Epics::CIP 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', 'cip.xml') ) } + subject { described_class.new(client, document) } + + describe 'order attributes' do + it { expect(subject.header.to_s).to include('OZHNN') } + it { expect(subject.header.to_s).to include('CIP') } + 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 +