epics 1.6.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,8 +36,10 @@ require "epics/ccs"
36
36
  require "epics/cdb"
37
37
  require "epics/cdd"
38
38
  require "epics/b2b"
39
+ require "epics/xds"
39
40
  require "epics/cds"
40
41
  require "epics/cdz"
42
+ require "epics/xct"
41
43
  require "epics/hia"
42
44
  require "epics/ini"
43
45
  require "epics/signer"
@@ -1,6 +1,6 @@
1
1
  class Epics::CCS < Epics::CCT
2
2
  def order_attribute
3
- "DZHNN"
3
+ 'DZHNN'
4
4
  end
5
5
 
6
6
  def order_type
@@ -1,4 +1,12 @@
1
1
  class Epics::CCT < Epics::GenericUploadRequest
2
+ def order_attribute
3
+ 'OZHNN'
4
+ end
5
+
6
+ def order_type
7
+ 'CCT'
8
+ end
9
+
2
10
  def header
3
11
  Nokogiri::XML::Builder.new do |xml|
4
12
  xml.header(authenticate: true) {
@@ -10,8 +18,8 @@ class Epics::CCT < Epics::GenericUploadRequest
10
18
  xml.UserID user_id
11
19
  xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
12
20
  xml.OrderDetails {
13
- xml.OrderType 'CCT'
14
- xml.OrderAttribute 'OZHNN'
21
+ xml.OrderType order_type
22
+ xml.OrderAttribute order_attribute
15
23
  xml.StandardOrderParams
16
24
  }
17
25
  xml.BankPubKeyDigests {
@@ -127,6 +127,10 @@ class Epics::Client
127
127
  upload(Epics::CD1, document)
128
128
  end
129
129
 
130
+ def CDB(document)
131
+ upload(Epics::CDB, document)
132
+ end
133
+
130
134
  def CDD(document)
131
135
  upload(Epics::CDD, document)
132
136
  end
@@ -135,6 +139,14 @@ class Epics::Client
135
139
  upload(Epics::CDS, document)
136
140
  end
137
141
 
142
+ def XDS(document)
143
+ upload(Epics::XDS, document)
144
+ end
145
+
146
+ def CDZ(document)
147
+ upload(Epics::CDZ, document)
148
+ end
149
+
138
150
  def CCT(document)
139
151
  upload(Epics::CCT, document)
140
152
  end
@@ -143,6 +155,10 @@ class Epics::Client
143
155
  upload(Epics::CCS, document)
144
156
  end
145
157
 
158
+ def XCT(document)
159
+ upload(Epics::XCT, document)
160
+ end
161
+
146
162
  def STA(from = nil, to = nil)
147
163
  download(Epics::STA, from, to)
148
164
  end
@@ -169,9 +185,9 @@ class Epics::Client
169
185
 
170
186
  def HTD
171
187
  Nokogiri::XML(download(Epics::HTD)).tap do |htd|
172
- @iban ||= htd.at_xpath("//xmlns:AccountNumber[@international='true']", xmlns: "urn:org:ebics:H004").text
173
- @bic ||= htd.at_xpath("//xmlns:BankCode[@international='true']", xmlns: "urn:org:ebics:H004").text
174
- @name ||= htd.at_xpath("//xmlns:Name", xmlns: "urn:org:ebics:H004").text
188
+ @iban ||= htd.at_xpath("//xmlns:AccountNumber[@international='true']", xmlns: "urn:org:ebics:H004").text rescue nil
189
+ @bic ||= htd.at_xpath("//xmlns:BankCode[@international='true']", xmlns: "urn:org:ebics:H004").text rescue nil
190
+ @name ||= htd.at_xpath("//xmlns:Name", xmlns: "urn:org:ebics:H004").text rescue nil
175
191
  @order_types ||= htd.search("//xmlns:OrderTypes", xmlns: "urn:org:ebics:H004").map{|o| o.content.split(/\s/) }.delete_if{|o| o == ""}.flatten
176
192
  end.to_xml
177
193
  end
@@ -231,11 +247,11 @@ class Epics::Client
231
247
  end
232
248
 
233
249
  def connection
234
- @connection ||= Faraday.new(headers: {user_agent: "EPICS v#{Epics::VERSION}"}, ssl: { verify: verify_ssl? }) do |faraday|
250
+ @connection ||= Faraday.new(headers: { 'Content-Type' => 'text/xml', user_agent: "EPICS v#{Epics::VERSION}"}, ssl: { verify: verify_ssl? }) do |faraday|
235
251
  faraday.use Epics::XMLSIG, { client: self }
236
252
  faraday.use Epics::ParseEbics, { client: self}
253
+ # faraday.use MyAdapter
237
254
  # faraday.response :logger # log requests to STDOUT
238
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
239
255
  end
240
256
  end
241
257
 
@@ -333,4 +333,4 @@ class Epics::Error < StandardError
333
333
  }
334
334
  end
335
335
 
336
- end
336
+ end
@@ -1,15 +1,16 @@
1
- class Epics::ParseEbics < Faraday::Middleware
1
+ # frozen_string_literal: true
2
2
 
3
+ class Epics::ParseEbics < Faraday::Middleware
3
4
  def initialize(app = nil, options = {})
4
5
  super(app)
5
6
  @client = options[:client]
6
7
  end
7
8
 
8
9
  def call(env)
9
- @app.call(env).on_complete do |env|
10
- env[:body] = ::Epics::Response.new(@client, env[:body])
11
- raise Epics::Error::TechnicalError.new(env[:body].technical_code) if env[:body].technical_error?
12
- raise Epics::Error::BusinessError.new(env[:body].business_code) if env[:body].business_error?
10
+ @app.call(env).on_complete do |response|
11
+ response.body = ::Epics::Response.new(@client, response.body)
12
+ raise(Epics::Error::TechnicalError, response.body.technical_code) if response.body.technical_error?
13
+ raise(Epics::Error::BusinessError, response.body.business_code) if response.body.business_error?
13
14
  end
14
15
  end
15
16
  end
@@ -6,13 +6,11 @@ class Epics::XMLSIG < Faraday::Middleware
6
6
  end
7
7
 
8
8
  def call(env)
9
- @signer = Epics::Signer.new(@client, env["body"])
9
+ @signer = Epics::Signer.new(@client, env.request_body)
10
10
  @signer.digest!
11
11
  @signer.sign!
12
12
 
13
- env["body"] = @signer.doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
14
-
13
+ env.request_body = @signer.doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
15
14
  @app.call(env)
16
15
  end
17
-
18
16
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Epics
2
- VERSION = "1.6.0"
4
+ VERSION = '1.8.1'
3
5
  end
@@ -0,0 +1,30 @@
1
+ class Epics::XCT < Epics::GenericUploadRequest
2
+ def header
3
+ Nokogiri::XML::Builder.new do |xml|
4
+ xml.header(authenticate: true) {
5
+ xml.static {
6
+ xml.HostID host_id
7
+ xml.Nonce nonce
8
+ xml.Timestamp timestamp
9
+ xml.PartnerID partner_id
10
+ xml.UserID user_id
11
+ xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
12
+ xml.OrderDetails {
13
+ xml.OrderType 'XCT'
14
+ xml.OrderAttribute 'OZHNN'
15
+ xml.StandardOrderParams
16
+ }
17
+ xml.BankPubKeyDigests {
18
+ xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
19
+ xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
20
+ }
21
+ xml.SecurityMedium '0000'
22
+ xml.NumSegments 1
23
+ }
24
+ xml.mutable {
25
+ xml.TransactionPhase 'Initialisation'
26
+ }
27
+ }
28
+ end.doc.root
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ class Epics::XDS < Epics::CDD
2
+ def order_type
3
+ 'XDS'
4
+ end
5
+ end
@@ -88,7 +88,7 @@ RSpec.describe Epics::Client do
88
88
  end
89
89
 
90
90
  it 'extracts the accessible order types of a subscriber' do
91
- 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 CDD))
91
+ 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))
92
92
  end
93
93
  end
94
94
 
@@ -130,6 +130,21 @@ RSpec.describe Epics::Client do
130
130
  end
131
131
  end
132
132
 
133
+
134
+ describe '#CDB' do
135
+ let(:cdb_document) { File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cdb.xml')) }
136
+ before do
137
+ stub_request(:post, "https://194.180.18.30/ebicsweb/ebicsweb")
138
+ .with(:body => %r[<TransactionPhase>Initialisation</TransactionPhase>])
139
+ .to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cdb_init_response.xml')))
140
+ stub_request(:post, "https://194.180.18.30/ebicsweb/ebicsweb")
141
+ .with(:body => %r[<TransactionPhase>Transfer</TransactionPhase>])
142
+ .to_return(status: 200, body: File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cdb_transfer_response.xml')))
143
+ end
144
+
145
+ it { expect(subject.CDB(cdb_document)).to eq(["387B7BE88FE33B0F4B60AC64A63F18E2","N00L"]) }
146
+ end
147
+
133
148
  describe '#CD1' do
134
149
  let(:cd1_document) { File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'cd1.xml')) }
135
150
  describe 'normal behaviour' do
@@ -182,6 +197,16 @@ RSpec.describe Epics::Client do
182
197
  it 'sets @order_types' do
183
198
  expect { subject.HTD }.to change { subject.instance_variable_get("@order_types") }
184
199
  end
200
+
201
+ describe 'without iban' do
202
+ before do
203
+ allow(subject).to receive(:download).and_return( File.read(File.join(File.dirname(__FILE__), 'fixtures', 'xml', 'htd_order_data_without_names.xml')))
204
+ end
205
+
206
+ it 'sets @iban' do
207
+ expect(subject.iban).to be_nil
208
+ end
209
+ end
185
210
  end
186
211
 
187
212
  describe '#C53/C52/C54 types with zipped data' do
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.003.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.003.02 pain.008.003.02.xsd">
3
+ <CstmrDrctDbtInitn>
4
+ <GrpHdr>
5
+ <MsgId>1434018161</MsgId>
6
+ <CreDtTm>2015-06-11T12:22:41+02:00</CreDtTm>
7
+ <NbOfTxs>1</NbOfTxs>
8
+ <CtrlSum>1.12</CtrlSum>
9
+ <InitgPty>
10
+ <Nm>Max Musterman</Nm>
11
+ </InitgPty>
12
+ </GrpHdr>
13
+ <PmtInf>
14
+ <PmtInfId>1434018161/1</PmtInfId>
15
+ <PmtMtd>DD</PmtMtd>
16
+ <BtchBookg>true</BtchBookg>
17
+ <NbOfTxs>1</NbOfTxs>
18
+ <CtrlSum>1.12</CtrlSum>
19
+ <PmtTpInf>
20
+ <SvcLvl>
21
+ <Cd>SEPA</Cd>
22
+ </SvcLvl>
23
+ <LclInstrm>
24
+ <Cd>B2B</Cd>
25
+ </LclInstrm>
26
+ <SeqTp>RCUR</SeqTp>
27
+ </PmtTpInf>
28
+ <ReqdColltnDt>2015-06-15</ReqdColltnDt>
29
+ <Cdtr>
30
+ <Nm>Max Mustermann</Nm>
31
+ </Cdtr>
32
+ <CdtrAcct>
33
+ <Id>
34
+ <IBAN>DE89370400440532013000</IBAN>
35
+ </Id>
36
+ </CdtrAcct>
37
+ <CdtrAgt>
38
+ <FinInstnId>
39
+ <BIC>COBADEFFXXX</BIC>
40
+ </FinInstnId>
41
+ </CdtrAgt>
42
+ <ChrgBr>SLEV</ChrgBr>
43
+ <CdtrSchmeId>
44
+ <Id>
45
+ <PrvtId>
46
+ <Othr>
47
+ <Id>DE98ZZZ09999999999</Id>
48
+ <SchmeNm>
49
+ <Prtry>SEPA</Prtry>
50
+ </SchmeNm>
51
+ </Othr>
52
+ </PrvtId>
53
+ </Id>
54
+ </CdtrSchmeId>
55
+ <DrctDbtTxInf>
56
+ <PmtId>
57
+ <EndToEndId>86</EndToEndId>
58
+ </PmtId>
59
+ <InstdAmt Ccy="EUR">1.12</InstdAmt>
60
+ <DrctDbtTx>
61
+ <MndtRltdInf>
62
+ <MndtId>M123123</MndtId>
63
+ <DtOfSgntr>2015-06-01</DtOfSgntr>
64
+ </MndtRltdInf>
65
+ </DrctDbtTx>
66
+ <DbtrAgt>
67
+ <FinInstnId>
68
+ <BIC>BKAUATWW</BIC>
69
+ </FinInstnId>
70
+ </DbtrAgt>
71
+ <Dbtr>
72
+ <Nm>Maria Musterfrau</Nm>
73
+ </Dbtr>
74
+ <DbtrAcct>
75
+ <Id>
76
+ <IBAN>AT611904300234573201</IBAN>
77
+ </Id>
78
+ </DbtrAcct>
79
+ <RmtInf>
80
+ <Ustrd>Purpose</Ustrd>
81
+ </RmtInf>
82
+ </DrctDbtTxInf>
83
+ </PmtInf>
84
+ </CstmrDrctDbtInitn>
85
+ </Document>
@@ -0,0 +1,31 @@
1
+ <ebicsResponse Revision="1" Version="H004" xsi:schemaLocation="urn:org:ebics:H004 ebics_response_H004.xsd" xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
2
+ <header authenticate="true">
3
+ <static>
4
+ <TransactionID>387B7BE88FE33B0F4B60AC64A63F18E2</TransactionID>
5
+ </static>
6
+ <mutable>
7
+ <TransactionPhase>Initialisation</TransactionPhase>
8
+ <OrderID>N00L</OrderID>
9
+ <ReturnCode>000000</ReturnCode>
10
+ <ReportText>[EBICS_OK] OK</ReportText>
11
+ </mutable>
12
+ </header>
13
+ <AuthSignature>
14
+ <ds:SignedInfo>
15
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
16
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
17
+ <ds:Reference URI="#xpointer(//*[@authenticate='true'])">
18
+ <ds:Transforms>
19
+ <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
20
+ </ds:Transforms>
21
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
22
+ <ds:DigestValue>hSf/fZURBW6ihKUUZDMRpqc3kloVZZRjw+DTBxjS7AM=</ds:DigestValue>
23
+ </ds:Reference>
24
+ </ds:SignedInfo>
25
+ <ds:SignatureValue>IFHzo6jch33gA0Ovxh4VWtAwJOJRdxffMy7Yi+a+UUWPM/ekNqcewCWxgjbcWgD/LiH6eQc58iKcZdNKpaKfplQ09CJi1VBry5sd97i4tlCAhoM95JTrJjp2O6PhswAo+a6dpuXmA11u57BK0/nHENMIh4+Qw3aGszn21Ft8qwo=</ds:SignatureValue>
26
+ </AuthSignature>
27
+ <body>
28
+ <ReturnCode authenticate="true">000000</ReturnCode>
29
+ <TimestampBankParameter authenticate="true">2007-10-19T14:58:39.467Z</TimestampBankParameter>
30
+ </body>
31
+ </ebicsResponse>
@@ -0,0 +1,32 @@
1
+ <ebicsResponse Revision="1" Version="H004" xsi:schemaLocation="urn:org:ebics:H004 ebics_response_H004.xsd" xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
2
+ <header authenticate="true">
3
+ <static>
4
+ <TransactionID>387B7BE88FE33B0F4B60AC64A63F18E2</TransactionID>
5
+ </static>
6
+ <mutable>
7
+ <TransactionPhase>Transfer</TransactionPhase>
8
+ <SegmentNumber lastSegment="true">1</SegmentNumber>
9
+ <OrderID>N00L</OrderID>
10
+ <ReturnCode>000000</ReturnCode>
11
+ <ReportText>[EBICS_OK] OK</ReportText>
12
+ </mutable>
13
+ </header>
14
+ <AuthSignature>
15
+ <ds:SignedInfo>
16
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
17
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
18
+ <ds:Reference URI="#xpointer(//*[@authenticate='true'])">
19
+ <ds:Transforms>
20
+ <ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
21
+ </ds:Transforms>
22
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
23
+ <ds:DigestValue></ds:DigestValue>
24
+ </ds:Reference>
25
+ </ds:SignedInfo>
26
+ <ds:SignatureValue></ds:SignatureValue>
27
+ </AuthSignature>
28
+ <body>
29
+ <ReturnCode authenticate="true">000000</ReturnCode>
30
+ <TimestampBankParameter authenticate="true">2007-10-19T14:58:39.467Z</TimestampBankParameter>
31
+ </body>
32
+ </ebicsResponse>
@@ -133,6 +133,12 @@
133
133
  <Description>CD1</Description>
134
134
  <NumSigRequired>1</NumSigRequired>
135
135
  </OrderInfo>
136
+ <OrderInfo>
137
+ <OrderType>CDB</OrderType>
138
+ <TransferType>Upload</TransferType>
139
+ <Description>CDB</Description>
140
+ <NumSigRequired>1</NumSigRequired>
141
+ </OrderInfo>
136
142
  <OrderInfo>
137
143
  <OrderType>CDD</OrderType>
138
144
  <TransferType>Upload</TransferType>
@@ -147,7 +153,7 @@
147
153
  <OrderTypes>PTK HPD HTD STA HVD HPB HAA HVT HVU HVZ</OrderTypes>
148
154
  </Permission>
149
155
  <Permission AuthorisationLevel="E">
150
- <OrderTypes>INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDD</OrderTypes>
156
+ <OrderTypes>INI SPR PUB HIA HCA HSA HVE HVS CCS CCT CD1 CDB CDD</OrderTypes>
151
157
  </Permission>
152
158
  </UserInfo>
153
- </HTDResponseOrderData>
159
+ </HTDResponseOrderData>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <HTDResponseOrderData xmlns="urn:org:ebics:H004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:ebics:H004 http://www.ebics.org/H004/ebics_orders_H004.xsd">
3
+ <PartnerInfo>
4
+ <AddressInfo>
5
+ <Name>Railslove GmbH</Name>
6
+ <Country>Deutschland</Country>
7
+ </AddressInfo>
8
+ <BankInfo>
9
+ <HostID>SIZBN001</HostID>
10
+ </BankInfo>
11
+ <OrderInfo>
12
+ <OrderType>HTD</OrderType>
13
+ <TransferType>Download</TransferType>
14
+ <Description>Kunden- und Teilnehmerdaten abholen</Description>
15
+ </OrderInfo>
16
+ </PartnerInfo>
17
+ <UserInfo>
18
+ <UserID Status="1">EBIX</UserID>
19
+ <Name>Ebi, Epics</Name>
20
+ <Permission>
21
+ <OrderTypes>HTD</OrderTypes>
22
+ </Permission>
23
+ <Permission AuthorisationLevel="E">
24
+ <OrderTypes></OrderTypes>
25
+ </Permission>
26
+ </UserInfo>
27
+ </HTDResponseOrderData>