Skip to content

Commit

Permalink
Merge pull request #133 from gadimbaylisahil/add-crz-and-make-date-ra…
Browse files Browse the repository at this point in the history
…nge-optional-for-cdz

Adds CRZ order type and makes date range optional for CDZ
  • Loading branch information
tobischo authored Sep 21, 2022
2 parents fdd7d7c + 21e833b commit eda0c0d
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/epics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
require "epics/xds"
require "epics/cds"
require "epics/cdz"
require "epics/crz"
require "epics/xct"
require "epics/hia"
require "epics/ini"
Expand Down
18 changes: 11 additions & 7 deletions lib/epics/cdz.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Epics::CDZ < Epics::GenericRequest
attr_accessor :from, :to

def initialize(client, from, to)
def initialize(client, from = nil, to = nil)
super(client)
self.from = from
self.to = to
Expand All @@ -20,13 +20,17 @@ def header
xml.OrderDetails {
xml.OrderType 'CDZ'
xml.OrderAttribute 'DZHNN'
xml.StandardOrderParams {
xml.DateRange {
xml.Start from
xml.End to
if !!from && !!to
xml.StandardOrderParams {
xml.DateRange {
xml.Start from
xml.End to
}
}
}
}
else
xml.StandardOrderParams
end
}
xml.BankPubKeyDigests {
xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
Expand Down
6 changes: 5 additions & 1 deletion lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,14 @@ def VMK(from = nil, to = nil)
download(Epics::VMK, from, to)
end

def CDZ(from, to)
def CDZ(from = nil, to = nil)
download_and_unzip(Epics::CDZ, from, to)
end

def CRZ(from = nil, to = nil)
download_and_unzip(Epics::CRZ, from, to)
end

def C52(from, to)
download_and_unzip(Epics::C52, from, to)
end
Expand Down
46 changes: 46 additions & 0 deletions lib/epics/crz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class Epics::CRZ < Epics::GenericRequest
attr_accessor :from, :to

def initialize(client, from = nil, to = nil)
super(client)
self.from = from
self.to = to
end

def header
Nokogiri::XML::Builder.new do |xml|
xml.header(authenticate: true) {
xml.static {
xml.HostID host_id
xml.Nonce nonce
xml.Timestamp timestamp
xml.PartnerID partner_id
xml.UserID user_id
xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
xml.OrderDetails {
xml.OrderType 'CRZ'
xml.OrderAttribute 'DZHNN'
if !!from && !!to
xml.StandardOrderParams {
xml.DateRange {
xml.Start from
xml.End to
}
}
else
xml.StandardOrderParams
end
}
xml.BankPubKeyDigests {
xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
}
xml.SecurityMedium '0000'
}
xml.mutable {
xml.TransactionPhase 'Initialisation'
}
}
end.doc.root
end
end
25 changes: 22 additions & 3 deletions spec/orders/cdz_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
RSpec.describe Epics::CDZ 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') }
subject { described_class.new(client, "2014-09-01", "2014-09-30") }

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }
context 'with date range' do
subject { described_class.new(client, "2014-09-01", "2014-09-30") }

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }

it 'does includes a date range as standard order parameter' do
expect(subject.to_xml).to include('<StandardOrderParams><DateRange><Start>2014-09-01</Start><End>2014-09-30</End></DateRange></StandardOrderParams>')
end
end
end

context 'without date range' do
subject { described_class.new(client) }

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }

it 'does not include a standard order parameter' do
expect(subject.to_xml).to include('<StandardOrderParams/>')
end
end
end
end
27 changes: 27 additions & 0 deletions spec/orders/crz_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
RSpec.describe Epics::CRZ 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') }

context 'with date range' do
subject { described_class.new(client, "2014-09-01", "2014-09-30") }

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }

it 'does includes a date range as standard order parameter' do
expect(subject.to_xml).to include('<StandardOrderParams><DateRange><Start>2014-09-01</Start><End>2014-09-30</End></DateRange></StandardOrderParams>')
end
end
end

context 'without date range' do
subject { described_class.new(client) }

describe '#to_xml' do
specify { expect(subject.to_xml).to be_a_valid_ebics_doc }

it 'does not include a standard order parameter' do
expect(subject.to_xml).to include('<StandardOrderParams/>')
end
end
end
end

0 comments on commit eda0c0d

Please sign in to comment.