Class: Ebics::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/ebics/client.rb
Constant Summary
collapse
- BANK_NAME =
'VALERIAN'
- URL_EBICS_SERVER =
'https://server-ebics.webank.fr:28103/WbkPortalFileTransfert/EbicsProtocol'
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#create_bank(url, name, host_id) ⇒ Object
-
#create_partner(bank, id) ⇒ Object
-
#create_user_directories(user) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
-
#load_user(bank_url, bank_name, host_id, partner_id, user_id, password) ⇒ Object
-
#log(name, *params) ⇒ Object
-
#messages ⇒ Object
-
#require_product(options) ⇒ Object
-
#require_user(options) ⇒ Object
-
#require_user_and_product(options) ⇒ Object
-
#t(name, *params) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
8
9
10
11
12
13
14
15
16
|
# File 'lib/ebics/client.rb', line 8
def initialize
self.conf = Java::OrgKopiEbicsSession.DefaultConfiguration.new
self.users = {}
self.banks = {}
self.partners = {}
messages.locale = conf.locale
conf.init
end
|
Instance Attribute Details
#banks ⇒ Object
Returns the value of attribute banks.
3
4
5
|
# File 'lib/ebics/client.rb', line 3
def banks
@banks
end
|
#conf ⇒ Object
Returns the value of attribute conf.
3
4
5
|
# File 'lib/ebics/client.rb', line 3
def conf
@conf
end
|
#partners ⇒ Object
Returns the value of attribute partners.
3
4
5
|
# File 'lib/ebics/client.rb', line 3
def partners
@partners
end
|
#users ⇒ Object
Returns the value of attribute users.
3
4
5
|
# File 'lib/ebics/client.rb', line 3
def users
@users
end
|
Instance Method Details
#create_bank(url, name, host_id) ⇒ Object
41
42
43
|
# File 'lib/ebics/client.rb', line 41
def create_bank(url, name, host_id)
banks[host_id] = Java::OrgKopiEbicsClient.Bank.new(Java::JavaNet::URL.new(url), name, host_id)
end
|
#create_partner(bank, id) ⇒ Object
45
46
47
|
# File 'lib/ebics/client.rb', line 45
def create_partner(bank, id)
partners[id] = Java::OrgKopiEbicsClient.Partner.new(bank, id)
end
|
#create_user_directories(user) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ebics/client.rb', line 30
def create_user_directories(user)
log 'user.create.directories', user.user_id
%w(get_user_directory
get_transfer_trace_directory
get_keystore_directory
get_letters_directory).each do |dir|
FileUtils.mkdir conf.send(dir, user)
end
end
|
#load_user(bank_url, bank_name, host_id, partner_id, user_id, password) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/ebics/client.rb', line 49
def load_user(bank_url, bank_name, host_id, partner_id, user_id, password)
bank = create_bank(bank_url, bank_name, host_id)
partner = create_partner(bank, partner_id)
users[user_id] = @user = Java::OrgKopiEbicsClient.User.new(partner, conf.serialization_manager.deserialize(user_id), password)
end
|
#log(name, *params) ⇒ Object
26
27
28
|
# File 'lib/ebics/client.rb', line 26
def log(name, *params)
conf.logger.info t(name, *params)
end
|
#messages ⇒ Object
18
19
20
|
# File 'lib/ebics/client.rb', line 18
def messages
Java::OrgKopiEbicsMessages.Messages
end
|
#require_product(options) ⇒ Object
72
73
74
|
# File 'lib/ebics/client.rb', line 72
def require_product(options)
@product = Java::OrgKopiEbicsSession.Product.new((options[:product_name] || 'kopiLeft Dev 1.0'), Java::JavaUtil.Locale::FRANCE, nil)
end
|
#require_user(options) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/ebics/client.rb', line 59
def require_user(options)
pwd = Java::OrgKopiEbicsSecurity.UserPasswordHandler.new(options[:user_id], options[:password])
load_user(
options[:bank_url] || URL_EBICS_SERVER,
options[:bank_name] || BANK_NAME,
options[:host_id],
options[:partner_id],
options[:user_id],
pwd
)
end
|
#require_user_and_product(options) ⇒ Object
76
77
78
79
80
|
# File 'lib/ebics/client.rb', line 76
def require_user_and_product(options)
require_user options
require_product options
end
|
#t(name, *params) ⇒ Object
22
23
24
|
# File 'lib/ebics/client.rb', line 22
def t(name, *params)
messages.get_string(name, Java::OrgKopiEbicsUtils.Constants.APPLICATION_BUNDLE_NAME)
end
|