Class: RubyIsds::Configuration
- Inherits:
-
Object
- Object
- RubyIsds::Configuration
- Defined in:
- lib/ruby_isds/configuration.rb
Constant Summary collapse
- ALLOWED_PRODUCTION_SYNTAX =
[:production, 'production'].freeze
Instance Attribute Summary collapse
-
#api_url ⇒ Object
writeonly
Sets the attribute api_url.
- #cert_file ⇒ Object
- #data_box ⇒ Object
-
#env ⇒ Object
env values: :development (default) :production.
- #key_file ⇒ Object
-
#pass_phrase ⇒ Object
Returns the value of attribute pass_phrase.
- #password ⇒ Object
- #username ⇒ Object
Instance Method Summary collapse
- #api_domain ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #private_key ⇒ Object
- #production? ⇒ Boolean
- #xml_url ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby_isds/configuration.rb', line 9 def initialize @username = nil @password = nil @data_box = nil @env = nil @cert_file = nil @key_file = nil @pass_phrase = nil end |
Instance Attribute Details
#api_url=(value) ⇒ Object (writeonly)
Sets the attribute api_url
3 4 5 |
# File 'lib/ruby_isds/configuration.rb', line 3 def api_url=(value) @api_url = value end |
#cert_file ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ruby_isds/configuration.rb', line 34 def cert_file if @cert_file && (!@key_file && !@pass_phrase) raise ConfigNotSet, 'pass_phrase and key_file' end return unless @cert_file OpenSSL::X509::Certificate.new(File.read(@cert_file)) end |
#data_box ⇒ Object
19 20 21 22 |
# File 'lib/ruby_isds/configuration.rb', line 19 def data_box raise ConfigNotSet, 'data_box' unless @data_box @data_box end |
#env ⇒ Object
env values:
:development (default)
:production
58 59 60 61 |
# File 'lib/ruby_isds/configuration.rb', line 58 def env return :development unless @env @env end |
#key_file ⇒ Object
42 43 44 45 |
# File 'lib/ruby_isds/configuration.rb', line 42 def key_file return nil unless @key_file File.read(@key_file) end |
#pass_phrase ⇒ Object
Returns the value of attribute pass_phrase.
5 6 7 |
# File 'lib/ruby_isds/configuration.rb', line 5 def pass_phrase @pass_phrase end |
#password ⇒ Object
29 30 31 32 |
# File 'lib/ruby_isds/configuration.rb', line 29 def password raise ConfigNotSet, 'password' unless @password @password end |
#username ⇒ Object
24 25 26 27 |
# File 'lib/ruby_isds/configuration.rb', line 24 def username raise ConfigNotSet, 'username' unless @username @username end |
Instance Method Details
#api_domain ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/ruby_isds/configuration.rb', line 63 def api_domain if production? return 'https://ws1c.mojedatovaschranka.cz/cert' if @cert_file 'https://ws1.mojedatovaschranka.cz' else return 'https://ws1c.czebox.cz/hspis' if @cert_file 'https://ws1.czebox.cz' end end |
#private_key ⇒ Object
47 48 49 50 51 |
# File 'lib/ruby_isds/configuration.rb', line 47 def private_key raise ConfigNotSet, 'pass_phrase' if @key_file && !@pass_phrase raise ConfigNotSet, 'key_file' if !@key_file && @pass_phrase OpenSSL::PKey::RSA.new(File.read(@key_file), @pass_phrase) end |
#production? ⇒ Boolean
78 79 80 |
# File 'lib/ruby_isds/configuration.rb', line 78 def production? ALLOWED_PRODUCTION_SYNTAX.include?(@env) end |
#xml_url ⇒ Object
73 74 75 76 |
# File 'lib/ruby_isds/configuration.rb', line 73 def xml_url return 'mojedatovaschranka.cz' if production? 'czechpoint.cz' end |