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

Added CIP use case #158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
require "epics/hpd"
require "epics/cd1"
require "epics/cct"
require "epics/cip"
require "epics/ccs"
require "epics/cdb"
require "epics/cdd"
Expand Down
14 changes: 14 additions & 0 deletions lib/epics/cip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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

8 changes: 8 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def credit(document)
self.CCT(document)
end

def inst(document)
self.CIP(document)
end

def debit(document, type = :CDD)
self.public_send(type, document)
end
Expand Down Expand Up @@ -166,6 +170,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
Expand Down
2 changes: 1 addition & 1 deletion lib/epics/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Epics
VERSION = '2.4.0'
VERSION = '2.4.0.a'
end
2 changes: 1 addition & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
83 changes: 83 additions & 0 deletions spec/fixtures/xml/cip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Mit XMLSpy v2022 rel. 2 sp2 (http://www.altova.com) im September 2022 von der SIZ GmbH (Wenzel) bearbeitet -->
<!-- Änderungen gegenüber der Vorfassung: KEINE - der Namespace ist weiterhin ISO-Version 2019, jedoch wird hier über das neue GBIC_4-Schema validiert, das weitere Optionen zulässt. Es sind z.B. strukturierte Adressangaben möglich -->
<!-- Dieses Beispiel wurde mit dem DK TVS pain.001.001.09_GBIC_4 erstellt und validiert -->
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09 pain.001.001.09.xsd">
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>Message-ID-4711</MsgId>
<CreDtTm>2021-07-29T09:30:47.000Z</CreDtTm>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>6655.86</CtrlSum>
<InitgPty>
<Nm>Initiator Name</Nm>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>Payment-Information-ID-4711</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<BtchBookg>true</BtchBookg>
<NbOfTxs>2</NbOfTxs>
<CtrlSum>6655.86</CtrlSum>
<PmtTpInf>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm><Cd>INST</Cd></LclInstrm>
</PmtTpInf>
<ReqdExctnDt><DtTm>2021-07-30T11:00:00</DtTm></ReqdExctnDt>
<Dbtr>
<Nm>Herr Schnellzahler</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE87200500001234567890</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<Othr><Id>NOTPROVIDED</Id></Othr>
</FinInstnId>
</DbtrAgt>
<ChrgBr>SLEV</ChrgBr>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>OriginatorID1234</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">6543.14</InstdAmt>
</Amt>
<Cdtr>
<Nm>Frau HatschnelldasGeld</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE21500500009876543210</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Unstructured Remittance Information</Ustrd>
</RmtInf>
</CdtTrfTxInf>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>OriginatorID1235</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">112.72</InstdAmt>
</Amt>
<Cdtr>
<Nm>Herr Instant</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE21500500001234567897</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Unstructured Remittance Information</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf>
</CstmrCdtTrfInitn>
</Document>
6 changes: 6 additions & 0 deletions spec/fixtures/xml/htd_order_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
<Description>Credit Transfer Initiation</Description>
<NumSigRequired>1</NumSigRequired>
</OrderInfo>
<OrderInfo>
<OrderType>CIP</OrderType>
<TransferType>Upload</TransferType>
<Description>Instant Credit Transfer Initiation</Description>
<NumSigRequired>1</NumSigRequired>
</OrderInfo>
<OrderInfo>
<OrderType>CD1</OrderType>
<TransferType>Upload</TransferType>
Expand Down
22 changes: 22 additions & 0 deletions spec/orders/cip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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('<OrderAttribute>OZHNN</OrderAttribute>') }
it { expect(subject.header.to_s).to include('<OrderType>CIP</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