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

Adds c2s support #148

Merged
merged 2 commits into from
Jun 4, 2024
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

- [ENHANCEMENT] Adds C2S order tyoe
- [HOUSEKEEPING] updates nokogiri dependency
- [HOUSEKEEPING] updates rexml dependency
- [HOUSEKEEPING] adds Ruby 3.3 to CI
Expand Down
4 changes: 2 additions & 2 deletions epics.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Gem::Specification.new do |spec|
spec.post_install_message += "\e[32m" + ('*' * 60) + "\n\e[0m"

spec.add_dependency 'faraday', '>= 1.10.0'
spec.add_dependency 'nokogiri', '>= 1.16.0'
spec.add_dependency 'nokogiri', '>= 1.16.5'
spec.add_dependency 'rubyzip', '>= 2.3.2'
spec.add_dependency 'rexml', '>= 3.2.6'
spec.add_dependency 'rexml', '>= 3.2.8'

spec.add_development_dependency 'bundler', '>= 2.4.12'
spec.add_development_dependency 'equivalent-xml'
Expand Down
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/b2b"
require "epics/xds"
require "epics/cds"
require "epics/c2s"
require "epics/cdz"
require "epics/crz"
require "epics/xct"
Expand Down
9 changes: 9 additions & 0 deletions lib/epics/c2s.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Epics::C2S < Epics::CDB
def order_attribute
"DZHNN"
end

def order_type
'C2S'
end
end
12 changes: 10 additions & 2 deletions lib/epics/cdb.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class Epics::CDB < Epics::GenericUploadRequest
def order_attribute
'OZHNN'
end

def order_type
'CDB'
end

def header
Nokogiri::XML::Builder.new do |xml|
xml.header(authenticate: true) {
Expand All @@ -10,8 +18,8 @@ def header
xml.UserID user_id
xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
xml.OrderDetails {
xml.OrderType 'CDB'
xml.OrderAttribute 'OZHNN'
xml.OrderType order_type
xml.OrderAttribute order_attribute
xml.StandardOrderParams
}
xml.BankPubKeyDigests {
Expand Down
4 changes: 4 additions & 0 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def CDB(document)
upload(Epics::CDB, document)
end

def C2S(document)
upload(Epics::C2S, document)
end

def CDD(document)
upload(Epics::CDD, document)
end
Expand Down
21 changes: 21 additions & 0 deletions spec/orders/c2s_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RSpec.describe Epics::C2S 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', 'cdb.xml') ) }
subject { described_class.new(client, document) }

describe 'order attributes' do
it { expect(subject.header.to_s).to include('<OrderAttribute>DZHNN</OrderAttribute>') }
it { expect(subject.header.to_s).to include('<OrderType>C2S</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