Class: Ebics::User::Creator

Inherits:
Client
  • Object
show all
Defined in:
lib/ebics/user/creator.rb

Constant Summary

Constants inherited from Client

Client::BANK_NAME, Client::URL_EBICS_SERVER

Instance Attribute Summary

Attributes inherited from Client

#banks, #conf, #partners, #users

Instance Method Summary collapse

Methods inherited from Client

#create_bank, #create_partner, #create_user_directories, #initialize, #load_user, #log, #messages, #require_product, #require_user, #require_user_and_product, #t

Constructor Details

This class inherits a constructor from Ebics::Client

Instance Method Details

#create_user(bank_url, bank_name, host_id, partner_id, user_id, name, email, country, organization, saveCertificates, password) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ebics/user/creator.rb', line 5

def create_user(
  bank_url,
  bank_name,
  host_id,
  partner_id,
  user_id,
  name,
  email,
  country,
  organization,
  saveCertificates,
  password)

  bank = create_bank(bank_url, bank_name, host_id)
  partner = create_partner(bank, partner_id)
  pwd = Java::OrgKopiEbicsSecurity.UserPasswordHandler.new(user_id, password)

  user = Java::OrgKopiEbicsClient.User.new(
    partner,
    user_id,
    name,
    email,
    country,
    organization,
    pwd
  )
  create_user_directories(user)

  user.save_user_certificates(conf.get_keystore_directory user) if saveCertificates

  sm = conf.serialization_manager
  [bank, partner, user].each do |o|
    sm.serialize o
  end

  load_letters(user)

  users[user_id] = user
end

#load_letters(user) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/ebics/user/creator.rb', line 45

def load_letters(user)
  lm = conf.letter_manager
  %w(a005 e002 x002).each do |format|
    letter = lm.send("create_#{format}_letter", user)
    letter.save(Java::JavaIo.FileOutputStream.new(
      File.join(conf.get_letters_directory(user), letter.name)
    ))
  end
end

#run(name, email, country, organization, saveCertificates, options) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ebics/user/creator.rb', line 55

def run(name, email, country, organization, saveCertificates, options)
  create_user(
    options[:bank_url],
    options[:bank_name],
    options[:host_id],
    options[:partner_id],
    options[:user_id],
    name,
    email,
    country,
    organization,
    saveCertificates,
    options[:password]
  )
end