epics 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.semaphore/semaphore.yml +3 -12
  3. data/CHANGELOG.md +14 -0
  4. data/epics.gemspec +9 -4
  5. data/lib/epics/azv.rb +9 -26
  6. data/lib/epics/b2b.rb +11 -3
  7. data/lib/epics/c2s.rb +11 -7
  8. data/lib/epics/c52.rb +12 -37
  9. data/lib/epics/c53.rb +12 -37
  10. data/lib/epics/c54.rb +12 -37
  11. data/lib/epics/c5n.rb +17 -0
  12. data/lib/epics/ccs.rb +11 -7
  13. data/lib/epics/cct.rb +9 -34
  14. data/lib/epics/cd1.rb +9 -26
  15. data/lib/epics/cdb.rb +9 -34
  16. data/lib/epics/cdd.rb +9 -34
  17. data/lib/epics/cds.rb +11 -7
  18. data/lib/epics/cdz.rb +12 -41
  19. data/lib/epics/cip.rb +13 -0
  20. data/lib/epics/client.rb +40 -19
  21. data/lib/epics/crz.rb +12 -41
  22. data/lib/epics/generic_request.rb +8 -3
  23. data/lib/epics/generic_upload_request.rb +2 -2
  24. data/lib/epics/haa.rb +8 -25
  25. data/lib/epics/hac.rb +12 -41
  26. data/lib/epics/header_request.rb +60 -0
  27. data/lib/epics/hia.rb +6 -16
  28. data/lib/epics/hkd.rb +8 -25
  29. data/lib/epics/hpb.rb +8 -18
  30. data/lib/epics/hpd.rb +8 -25
  31. data/lib/epics/htd.rb +8 -25
  32. data/lib/epics/ini.rb +6 -16
  33. data/lib/epics/letter_renderer.rb +22 -0
  34. data/lib/epics/ptk.rb +12 -41
  35. data/lib/epics/sta.rb +12 -41
  36. data/lib/epics/version.rb +1 -1
  37. data/lib/epics/vmk.rb +12 -41
  38. data/lib/epics/wss.rb +13 -0
  39. data/lib/epics/xct.rb +9 -26
  40. data/lib/epics/xds.rb +11 -3
  41. data/lib/epics/xe2.rb +11 -3
  42. data/lib/epics/xe3.rb +11 -3
  43. data/lib/epics/z52.rb +12 -37
  44. data/lib/epics/z53.rb +12 -37
  45. data/lib/epics/z54.rb +12 -37
  46. data/lib/epics.rb +8 -0
  47. data/lib/letter/ini.erb +260 -150
  48. data/lib/letter/locales/de.yml +19 -0
  49. data/lib/letter/locales/en.yml +19 -0
  50. data/lib/letter/locales/fr.yml +19 -0
  51. data/spec/client_spec.rb +1 -1
  52. data/spec/fixtures/xml/cip.xml +86 -0
  53. data/spec/fixtures/xml/htd_order_data.xml +7 -1
  54. data/spec/hpb_spec.rb +4 -4
  55. data/spec/orders/c52_spec.rb +1 -1
  56. data/spec/orders/c53_spec.rb +1 -1
  57. data/spec/orders/c54_spec.rb +1 -1
  58. data/spec/orders/c5n_spec.rb +9 -0
  59. data/spec/orders/cdz_spec.rb +1 -1
  60. data/spec/orders/cip_spec.rb +23 -0
  61. data/spec/orders/crz_spec.rb +1 -1
  62. data/spec/orders/hac_spec.rb +1 -1
  63. data/spec/orders/ptk_spec.rb +1 -1
  64. data/spec/orders/sta_spec.rb +1 -1
  65. data/spec/orders/vmk_spec.rb +1 -1
  66. data/spec/orders/wss_spec.rb +9 -0
  67. data/spec/orders/z52_spec.rb +1 -1
  68. data/spec/orders/z53_spec.rb +1 -1
  69. data/spec/orders/z54_spec.rb +1 -1
  70. metadata +44 -11
data/lib/epics/cip.rb ADDED
@@ -0,0 +1,13 @@
1
+ class Epics::CIP < Epics::GenericUploadRequest
2
+ def header
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'CIP',
7
+ order_attribute: 'OZHNN',
8
+ order_params: {},
9
+ num_segments: 1,
10
+ mutable: { TransactionPhase: 'Initialisation' }
11
+ )
12
+ end
13
+ end
data/lib/epics/client.rb CHANGED
@@ -3,6 +3,7 @@ class Epics::Client
3
3
 
4
4
  attr_accessor :passphrase, :url, :host_id, :user_id, :partner_id, :keys, :keys_content
5
5
  attr_writer :iban, :bic, :name
6
+ attr_accessor :locale
6
7
 
7
8
  def_delegators :connection, :post
8
9
 
@@ -14,6 +15,7 @@ class Epics::Client
14
15
  self.host_id = host_id
15
16
  self.user_id = user_id
16
17
  self.partner_id = partner_id
18
+ self.locale = :de
17
19
  end
18
20
 
19
21
  def inspect
@@ -68,9 +70,12 @@ class Epics::Client
68
70
  client
69
71
  end
70
72
 
73
+ def letter_renderer
74
+ @letter_renderer ||= Epics::LetterRenderer.new(self)
75
+ end
76
+
71
77
  def ini_letter(bankname)
72
- raw = File.read(File.join(File.dirname(__FILE__), '../letter/', 'ini.erb'))
73
- ERB.new(raw).result(binding)
78
+ letter_renderer.render(bankname)
74
79
  end
75
80
 
76
81
  def save_ini_letter(bankname, path)
@@ -78,6 +83,10 @@ class Epics::Client
78
83
  path
79
84
  end
80
85
 
86
+ def header_request
87
+ @header_request ||= Epics::HeaderRequest.new(self)
88
+ end
89
+
81
90
  def credit(document)
82
91
  self.CCT(document)
83
92
  end
@@ -87,7 +96,7 @@ class Epics::Client
87
96
  end
88
97
 
89
98
  def statements(from, to, type = :STA)
90
- self.public_send(type, from, to)
99
+ self.public_send(type, from: from, to: to)
91
100
  end
92
101
 
93
102
  def HIA
@@ -157,6 +166,10 @@ class Epics::Client
157
166
  upload(Epics::CCT, document)
158
167
  end
159
168
 
169
+ def CIP(document)
170
+ upload(Epics::CIP, document)
171
+ end
172
+
160
173
  def CCS(document)
161
174
  upload(Epics::CCS, document)
162
175
  end
@@ -166,43 +179,47 @@ class Epics::Client
166
179
  end
167
180
 
168
181
  def STA(from = nil, to = nil)
169
- download(Epics::STA, from, to)
182
+ download(Epics::STA, from: from, to: to)
170
183
  end
171
184
 
172
185
  def VMK(from = nil, to = nil)
173
- download(Epics::VMK, from, to)
186
+ download(Epics::VMK, from: from, to: to)
174
187
  end
175
188
 
176
189
  def CDZ(from = nil, to = nil)
177
- download_and_unzip(Epics::CDZ, from, to)
190
+ download_and_unzip(Epics::CDZ, from: from, to: to)
178
191
  end
179
192
 
180
193
  def CRZ(from = nil, to = nil)
181
- download_and_unzip(Epics::CRZ, from, to)
194
+ download_and_unzip(Epics::CRZ, from: from, to: to)
182
195
  end
183
196
 
184
197
  def C52(from, to)
185
- download_and_unzip(Epics::C52, from, to)
198
+ download_and_unzip(Epics::C52, from: from, to: to)
186
199
  end
187
200
 
188
201
  def C53(from, to)
189
- download_and_unzip(Epics::C53, from, to)
202
+ download_and_unzip(Epics::C53, from: from, to: to)
190
203
  end
191
204
 
192
205
  def C54(from, to)
193
- download_and_unzip(Epics::C54, from, to)
206
+ download_and_unzip(Epics::C54, from: from, to: to)
207
+ end
208
+
209
+ def C5N(from, to)
210
+ download_and_unzip(Epics::C5N, from: from, to: to)
194
211
  end
195
212
 
196
213
  def Z52(from, to)
197
- download_and_unzip(Epics::Z52, from, to)
214
+ download_and_unzip(Epics::Z52, from: from, to: to)
198
215
  end
199
216
 
200
217
  def Z53(from, to)
201
- download_and_unzip(Epics::Z53, from, to)
218
+ download_and_unzip(Epics::Z53, from: from, to: to)
202
219
  end
203
220
 
204
221
  def Z54(from, to)
205
- download_and_unzip(Epics::Z54, from, to)
222
+ download_and_unzip(Epics::Z54, from: from, to: to)
206
223
  end
207
224
 
208
225
  def HAA
@@ -227,11 +244,15 @@ class Epics::Client
227
244
  end
228
245
 
229
246
  def PTK(from, to)
230
- download(Epics::PTK, from, to)
247
+ download(Epics::PTK, from: from, to: to)
231
248
  end
232
249
 
233
250
  def HAC(from = nil, to = nil)
234
- download(Epics::HAC, from, to)
251
+ download(Epics::HAC, from: from, to: to)
252
+ end
253
+
254
+ def WSS
255
+ download(Epics::WSS)
235
256
  end
236
257
 
237
258
  def save_keys(path)
@@ -252,8 +273,8 @@ class Epics::Client
252
273
  return res.transaction_id, [res.order_id, order_id].detect { |id| id.to_s.chars.any? }
253
274
  end
254
275
 
255
- def download(order_type, *args)
256
- document = order_type.new(self, *args)
276
+ def download(order_type, *args, **options)
277
+ document = order_type.new(self, *args, **options)
257
278
  res = post(url, document.to_xml).body
258
279
  document.transaction_id = res.transaction_id
259
280
 
@@ -264,9 +285,9 @@ class Epics::Client
264
285
  res.order_data
265
286
  end
266
287
 
267
- def download_and_unzip(order_type, *args)
288
+ def download_and_unzip(order_type, *args, **options)
268
289
  [].tap do |entries|
269
- Zip::File.open_buffer(StringIO.new(download(order_type, *args))).each do |zipfile|
290
+ Zip::File.open_buffer(StringIO.new(download(order_type, *args, **options))).each do |zipfile|
270
291
  entries << zipfile.get_input_stream.read
271
292
  end
272
293
  end
data/lib/epics/crz.rb CHANGED
@@ -1,46 +1,17 @@
1
1
  class Epics::CRZ < Epics::GenericRequest
2
- attr_accessor :from, :to
3
-
4
- def initialize(client, from = nil, to = nil)
5
- super(client)
6
- self.from = from
7
- self.to = to
8
- end
9
-
10
2
  def header
11
- Nokogiri::XML::Builder.new do |xml|
12
- xml.header(authenticate: true) {
13
- xml.static {
14
- xml.HostID host_id
15
- xml.Nonce nonce
16
- xml.Timestamp timestamp
17
- xml.PartnerID partner_id
18
- xml.UserID user_id
19
- xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
20
- xml.OrderDetails {
21
- xml.OrderType 'CRZ'
22
- xml.OrderAttribute 'DZHNN'
23
- if !!from && !!to
24
- xml.StandardOrderParams {
25
- xml.DateRange {
26
- xml.Start from
27
- xml.End to
28
- }
29
- }
30
- else
31
- xml.StandardOrderParams
32
- end
33
- }
34
- xml.BankPubKeyDigests {
35
- xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
36
- xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
37
- }
38
- xml.SecurityMedium '0000'
39
- }
40
- xml.mutable {
41
- xml.TransactionPhase 'Initialisation'
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'CRZ',
7
+ order_attribute: 'DZHNN',
8
+ order_params: !!options[:from] && !!options[:to] ? {
9
+ DateRange: {
10
+ Start: options[:from],
11
+ End: options[:to]
42
12
  }
43
- }
44
- end.doc.root
13
+ } : {},
14
+ mutable: { TransactionPhase: 'Initialisation' }
15
+ )
45
16
  end
46
17
  end
@@ -1,10 +1,11 @@
1
1
  class Epics::GenericRequest
2
2
  extend Forwardable
3
- attr_accessor :client
3
+ attr_reader :client, :options
4
4
  attr_accessor :transaction_id
5
5
 
6
- def initialize(client)
7
- self.client = client
6
+ def initialize(client, **options)
7
+ @client = client
8
+ @options = options
8
9
  end
9
10
 
10
11
  def nonce
@@ -27,6 +28,10 @@ class Epics::GenericRequest
27
28
  end.doc.root
28
29
  end
29
30
 
31
+ def header
32
+ raise NotImplementedError
33
+ end
34
+
30
35
  def auth_signature
31
36
  Nokogiri::XML::Builder.new do |xml|
32
37
  xml.AuthSignature{
@@ -3,8 +3,8 @@ class Epics::GenericUploadRequest < Epics::GenericRequest
3
3
  attr_accessor :iv
4
4
  attr_accessor :document
5
5
 
6
- def initialize(client, document)
7
- super(client)
6
+ def initialize(client, document, **options)
7
+ super(client, **options)
8
8
  self.document = document
9
9
  self.key = cipher.random_key
10
10
  self.iv = 0.chr * cipher.iv_len
data/lib/epics/haa.rb CHANGED
@@ -1,29 +1,12 @@
1
1
  class Epics::HAA < Epics::GenericRequest
2
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 'HAA'
14
- xml.OrderAttribute 'DZHNN'
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
- }
23
- xml.mutable {
24
- xml.TransactionPhase 'Initialisation'
25
- }
26
- }
27
- end.doc.root
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'HAA',
7
+ order_attribute: 'DZHNN',
8
+ order_params: {},
9
+ mutable: { TransactionPhase: 'Initialisation' }
10
+ )
28
11
  end
29
12
  end
data/lib/epics/hac.rb CHANGED
@@ -1,49 +1,20 @@
1
1
  class Epics::HAC < Epics::GenericRequest
2
- attr_accessor :from, :to
3
-
4
2
  # By default HAC only returns data for transactions which have not yet been fetched. Therefore,
5
3
  # most applications not not have to specify a date range, but can simply fetch the status and
6
4
  # be done
7
- def initialize(client, from = nil, to = nil)
8
- super(client)
9
- self.from = from
10
- self.to = to
11
- end
12
-
13
5
  def header
14
- Nokogiri::XML::Builder.new do |xml|
15
- xml.header(authenticate: true) {
16
- xml.static {
17
- xml.HostID host_id
18
- xml.Nonce nonce
19
- xml.Timestamp timestamp
20
- xml.PartnerID partner_id
21
- xml.UserID user_id
22
- xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
23
- xml.OrderDetails {
24
- xml.OrderType 'HAC'
25
- xml.OrderAttribute 'DZHNN'
26
- if !!from && !!to
27
- xml.StandardOrderParams {
28
- xml.DateRange {
29
- xml.Start from
30
- xml.End to
31
- }
32
- }
33
- else
34
- xml.StandardOrderParams
35
- end
36
- }
37
- xml.BankPubKeyDigests {
38
- xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256")
39
- xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256" )
40
- }
41
- xml.SecurityMedium '0000'
42
- }
43
- xml.mutable {
44
- xml.TransactionPhase 'Initialisation'
6
+ client.header_request.build(
7
+ nonce: nonce,
8
+ timestamp: timestamp,
9
+ order_type: 'HAC',
10
+ order_attribute: 'DZHNN',
11
+ order_params: !!options[:from] && !!options[:to] ? {
12
+ DateRange: {
13
+ Start: options[:from],
14
+ End: options[:to]
45
15
  }
46
- }
47
- end.doc.root
16
+ } : {},
17
+ mutable: { TransactionPhase: 'Initialisation' }
18
+ )
48
19
  end
49
20
  end
@@ -0,0 +1,60 @@
1
+ class Epics::HeaderRequest
2
+ extend Forwardable
3
+ attr_accessor :client
4
+
5
+ PRODUCT_NAME = 'EPICS - a ruby ebics kernel'
6
+ PRODUCT_LANG = 'de'
7
+
8
+ def initialize(client)
9
+ self.client = client
10
+ end
11
+
12
+ def_delegators :client, :host_id, :user_id, :partner_id
13
+
14
+ def build(options = {})
15
+ options[:with_bank_pubkey_digests] = true if options[:with_bank_pubkey_digests].nil?
16
+
17
+ Nokogiri::XML::Builder.new do |xml|
18
+ xml.header(authenticate: true) {
19
+ xml.static {
20
+ xml.HostID host_id
21
+ xml.Nonce options[:nonce] if options[:nonce]
22
+ xml.Timestamp options[:timestamp] if options[:timestamp]
23
+ xml.PartnerID partner_id
24
+ xml.UserID user_id
25
+ xml.Product(PRODUCT_NAME, 'Language' => PRODUCT_LANG)
26
+ xml.OrderDetails {
27
+ xml.OrderType options[:order_type]
28
+ xml.OrderAttribute options[:order_attribute]
29
+ xml.StandardOrderParams {
30
+ build_attributes(xml, options[:order_params])
31
+ } if options[:order_params]
32
+ }
33
+ xml.BankPubKeyDigests {
34
+ xml.Authentication(client.bank_x.public_digest, Version: 'X002', Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256')
35
+ xml.Encryption(client.bank_e.public_digest, Version: 'E002', Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256')
36
+ } if options[:with_bank_pubkey_digests]
37
+ xml.SecurityMedium '0000'
38
+ xml.NumSegments options[:num_segments] if options[:num_segments]
39
+ }
40
+ xml.mutable {
41
+ build_attributes(xml, options[:mutable])
42
+ } if options[:mutable]
43
+ }
44
+ end.doc.root
45
+ end
46
+
47
+ private
48
+
49
+ def build_attributes(xml, attributes)
50
+ attributes.each do |key, value|
51
+ if value.is_a?(Hash)
52
+ xml.send(key) {
53
+ build_attributes(xml, value)
54
+ }
55
+ else
56
+ xml.send(key, value)
57
+ end
58
+ end
59
+ end
60
+ end
data/lib/epics/hia.rb CHANGED
@@ -4,22 +4,12 @@ class Epics::HIA < Epics::GenericRequest
4
4
  end
5
5
 
6
6
  def header
7
- Nokogiri::XML::Builder.new do |xml|
8
- xml.header(authenticate: true) {
9
- xml.static {
10
- xml.HostID host_id
11
- xml.PartnerID partner_id
12
- xml.UserID user_id
13
- xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
14
- xml.OrderDetails {
15
- xml.OrderType 'HIA'
16
- xml.OrderAttribute 'DZNNN'
17
- }
18
- xml.SecurityMedium '0000'
19
- }
20
- xml.mutable ''
21
- }
22
- end.doc.root
7
+ client.header_request.build(
8
+ order_type: 'HIA',
9
+ order_attribute: 'DZNNN',
10
+ with_bank_pubkey_digests: false,
11
+ mutable: {}
12
+ )
23
13
  end
24
14
 
25
15
  def body
data/lib/epics/hkd.rb CHANGED
@@ -1,29 +1,12 @@
1
1
  class Epics::HKD < Epics::GenericRequest
2
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 'HKD'
14
- xml.OrderAttribute 'DZHNN'
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
- }
23
- xml.mutable {
24
- xml.TransactionPhase 'Initialisation'
25
- }
26
- }
27
- end.doc.root
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'HKD',
7
+ order_attribute: 'DZHNN',
8
+ order_params: {},
9
+ mutable: { TransactionPhase: 'Initialisation' }
10
+ )
28
11
  end
29
12
  end
data/lib/epics/hpb.rb CHANGED
@@ -4,23 +4,13 @@ class Epics::HPB < Epics::GenericRequest
4
4
  end
5
5
 
6
6
  def header
7
- Nokogiri::XML::Builder.new do |xml|
8
- xml.header(authenticate: true) {
9
- xml.static {
10
- xml.HostID host_id
11
- xml.Nonce nonce
12
- xml.Timestamp timestamp
13
- xml.PartnerID partner_id
14
- xml.UserID user_id
15
- xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
16
- xml.OrderDetails {
17
- xml.OrderType 'HPB'
18
- xml.OrderAttribute 'DZHNN'
19
- }
20
- xml.SecurityMedium '0000'
21
- }
22
- xml.mutable ''
23
- }
24
- end.doc.root
7
+ client.header_request.build(
8
+ nonce: nonce,
9
+ timestamp: timestamp,
10
+ order_type: 'HPB',
11
+ order_attribute: 'DZHNN',
12
+ with_bank_pubkey_digests: false,
13
+ mutable: {}
14
+ )
25
15
  end
26
16
  end
data/lib/epics/hpd.rb CHANGED
@@ -1,29 +1,12 @@
1
1
  class Epics::HPD < Epics::GenericRequest
2
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 'HPD'
14
- xml.OrderAttribute 'DZHNN'
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
- }
23
- xml.mutable {
24
- xml.TransactionPhase 'Initialisation'
25
- }
26
- }
27
- end.doc.root
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'HPD',
7
+ order_attribute: 'DZHNN',
8
+ order_params: {},
9
+ mutable: { TransactionPhase: 'Initialisation' }
10
+ )
28
11
  end
29
12
  end
data/lib/epics/htd.rb CHANGED
@@ -1,29 +1,12 @@
1
1
  class Epics::HTD < Epics::GenericRequest
2
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 'HTD'
14
- xml.OrderAttribute 'DZHNN'
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
- }
23
- xml.mutable {
24
- xml.TransactionPhase 'Initialisation'
25
- }
26
- }
27
- end.doc.root
3
+ client.header_request.build(
4
+ nonce: nonce,
5
+ timestamp: timestamp,
6
+ order_type: 'HTD',
7
+ order_attribute: 'DZHNN',
8
+ order_params: {},
9
+ mutable: { TransactionPhase: 'Initialisation' }
10
+ )
28
11
  end
29
12
  end
data/lib/epics/ini.rb CHANGED
@@ -4,22 +4,12 @@ class Epics::INI < Epics::GenericRequest
4
4
  end
5
5
 
6
6
  def header
7
- Nokogiri::XML::Builder.new do |xml|
8
- xml.header(authenticate: true) {
9
- xml.static {
10
- xml.HostID host_id
11
- xml.PartnerID partner_id
12
- xml.UserID user_id
13
- xml.Product("EPICS - a ruby ebics kernel", 'Language' => 'de')
14
- xml.OrderDetails {
15
- xml.OrderType 'INI'
16
- xml.OrderAttribute 'DZNNN'
17
- }
18
- xml.SecurityMedium '0000'
19
- }
20
- xml.mutable ''
21
- }
22
- end.doc.root
7
+ client.header_request.build(
8
+ order_type: 'INI',
9
+ order_attribute: 'DZNNN',
10
+ with_bank_pubkey_digests: false,
11
+ mutable: {},
12
+ )
23
13
  end
24
14
 
25
15
  def body
@@ -0,0 +1,22 @@
1
+ class Epics::LetterRenderer
2
+ extend Forwardable
3
+
4
+ TEMPLATE_PATH = File.join(File.dirname(__FILE__), '../letter/', 'ini.erb')
5
+ I18N_SCOPE = 'epics.letter'
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def translate(key, **options)
12
+ I18n.translate(key, **{ locale: @client.locale, scope: I18N_SCOPE }.merge(options))
13
+ end
14
+
15
+ alias_method :t, :translate
16
+
17
+ def_delegators :@client, :host_id, :user_id, :partner_id, :a, :x, :e
18
+
19
+ def render(bankname)
20
+ ERB.new(File.read(TEMPLATE_PATH)).result(binding)
21
+ end
22
+ end