Skip to content

Commit ba6d864

Browse files
jplottobischo
authored andcommitted
Add HEV EBICS Order type support
1 parent 552371f commit ba6d864

6 files changed

Lines changed: 52 additions & 3 deletions

File tree

lib/epics.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
require "epics/xct"
5757
require "epics/hia"
5858
require "epics/ini"
59+
require "epics/hev"
5960
require "epics/signer"
6061
require "epics/client"
6162

lib/epics/client.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def INI
107107
post(url, Epics::INI.new(self).to_xml).body.ok?
108108
end
109109

110+
def HEV
111+
res = post(url, Epics::HEV.new(self).to_xml).body
112+
res.doc.xpath("//xmlns:VersionNumber", xmlns: 'http://www.ebics.org/H000').each_with_object({}) do |node, versions|
113+
versions[node['ProtocolVersion']] = node.content
114+
end
115+
end
116+
110117
def HPB
111118
Nokogiri::XML(download(Epics::HPB)).xpath("//xmlns:PubKeyValue", xmlns: "urn:org:ebics:H004").each do |node|
112119
type = node.parent.last_element_child.content

lib/epics/hev.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Epics::HEV < Epics::GenericRequest
2+
def root
3+
"ebicsHEVRequest"
4+
end
5+
6+
def body
7+
Nokogiri::XML::Builder.new do |xml|
8+
xml.HostID host_id
9+
end.doc.root
10+
end
11+
12+
def to_xml
13+
Nokogiri::XML::Builder.new do |xml|
14+
xml.send(root, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://www.ebics.org/H000 http://www.ebics.org/H000/ebics_hev.xsd', 'xmlns' => 'http://www.ebics.org/H000') {
15+
xml.parent.add_child(body)
16+
}
17+
end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML, encoding: 'utf-8')
18+
end
19+
end

lib/epics/response.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ def technical_error?
1212
end
1313

1414
def technical_code
15+
mutable_return_code.empty? ? system_return_code : mutable_return_code
16+
end
17+
18+
def mutable_return_code
1519
doc.xpath("//xmlns:header/xmlns:mutable/xmlns:ReturnCode", xmlns: "urn:org:ebics:H004").text
1620
end
1721

22+
def system_return_code
23+
doc.xpath("//xmlns:SystemReturnCode/xmlns:ReturnCode", xmlns: 'http://www.ebics.org/H000').text
24+
end
25+
1826
def business_error?
1927
!["", "000000"].include?(business_code)
2028
end

lib/epics/signer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def digest!
1717
end
1818

1919
def sign!
20-
signature_value_node = doc.xpath("//ds:SignatureValue").first
20+
signature_value_node = doc.xpath("//ds:SignatureValue", ds: "http://www.w3.org/2000/09/xmldsig#").first
2121

2222
if signature_node
2323
signature_value_node.content = Base64.encode64(client.x.key.sign(digester, signature_node.canonicalize)).gsub(/\n/,'')
@@ -27,11 +27,11 @@ def sign!
2727
end
2828

2929
def digest_node
30-
@d ||= doc.xpath("//ds:DigestValue").first
30+
@d ||= doc.xpath("//ds:DigestValue", ds: "http://www.w3.org/2000/09/xmldsig#").first
3131
end
3232

3333
def signature_node
34-
@s ||= doc.xpath("//ds:SignedInfo").first
34+
@s ||= doc.xpath("//ds:SignedInfo", ds: "http://www.w3.org/2000/09/xmldsig#").first
3535
end
3636

3737
def digester

spec/orders/hev_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
RSpec.describe Epics::HEV do
2+
3+
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') }
4+
5+
let(:xsd) { Nokogiri::XML::Schema(File.open( File.join( File.dirname(__FILE__), '..', 'xsd', 'ebics_hev.xsd') )) }
6+
let(:validator) { xsd.valid?(Nokogiri::XML(subject.to_xml)) }
7+
8+
subject { described_class.new(client) }
9+
10+
describe '#to_xml' do
11+
specify { expect(validator).to be_truthy }
12+
end
13+
14+
end

0 commit comments

Comments
 (0)