Skip to content

Commit

Permalink
Fixes after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jplot committed Oct 1, 2024
1 parent d8e35b4 commit 6ea5cbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/epics/header_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ class Epics::HeaderRequest
extend Forwardable
attr_accessor :client

BASE36_ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

PRODUCT_NAME = 'EPICS - a ruby ebics kernel'
PRODUCT_LANG = 'de'

Expand All @@ -15,6 +13,7 @@ def initialize(client)

def build(options = {})
options[:with_bank_pubkey_digests] = true if options[:with_bank_pubkey_digests].nil?
options[:security_medium] = 0 if options[:security_medium].nil?

Nokogiri::XML::Builder.new do |xml|
xml.header(authenticate: true) {
Expand All @@ -27,7 +26,7 @@ def build(options = {})
xml.Product(PRODUCT_NAME, 'Language' => PRODUCT_LANG)
xml.OrderDetails {
xml.OrderType options[:order_type]
xml.OrderID b36encode(client.next_order_id).rjust(4, '0') if client.version == Epics::Client::VERSION_H3
xml.OrderID b36encode(client.next_order_id) if client.version == Epics::Client::VERSION_H3
xml.OrderAttribute options[:order_attribute]
xml.StandardOrderParams {
build_attributes(xml, options[:order_params])
Expand All @@ -37,7 +36,7 @@ def build(options = {})
xml.Authentication(client.bank_authentication_key.public_digest, Version: client.authentication_version, Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256')
xml.Encryption(client.bank_encryption_key.public_digest, Version: client.encryption_version, Algorithm: 'http://www.w3.org/2001/04/xmlenc#sha256')
} if options[:with_bank_pubkey_digests]
xml.SecurityMedium '0000'
xml.SecurityMedium b36encode(options[:security_medium]) if options[:security_medium]
xml.NumSegments options[:num_segments] if options[:num_segments]
}
xml.mutable {
Expand All @@ -62,11 +61,6 @@ def build_attributes(xml, attributes)
end

def b36encode(number)
str = ''
while number > 0
number, i = number.divmod(36)
str += BASE36_ALPHABET[i]
end
str.empty? ? '0' : str
number.to_s(36).upcase.rjust(4, '0')
end
end
File renamed without changes.

0 comments on commit 6ea5cbc

Please sign in to comment.