Class: Wsaa::Configuration
- Inherits:
-
Object
- Object
- Wsaa::Configuration
- Defined in:
- lib/wsaa/configuration.rb
Overview
Holds configuration for the WSAA client.
Constant Summary collapse
- ENDPOINTS =
{ testing: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms', production: 'https://wsaa.afip.gov.ar/ws/services/LoginCms' }.freeze
Instance Attribute Summary collapse
-
#cache_dir ⇒ Object
Returns the value of attribute cache_dir.
-
#cert ⇒ Object
Returns the value of attribute cert.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#pkey ⇒ Object
Returns the value of attribute pkey.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
-
#endpoint ⇒ String
Returns the WSAA endpoint URL for the current environment.
-
#initialize ⇒ Configuration
constructor
Creates a new Configuration with default values.
-
#validate! ⇒ true
Validates the configuration.
Constructor Details
#initialize ⇒ Configuration
Creates a new Configuration with default values.
20 21 22 23 24 |
# File 'lib/wsaa/configuration.rb', line 20 def initialize @environment = :testing @service = 'wsfe' @cache_dir = '/tmp' end |
Instance Attribute Details
#cache_dir ⇒ Object
Returns the value of attribute cache_dir.
16 17 18 |
# File 'lib/wsaa/configuration.rb', line 16 def cache_dir @cache_dir end |
#cert ⇒ Object
Returns the value of attribute cert.
16 17 18 |
# File 'lib/wsaa/configuration.rb', line 16 def cert @cert end |
#environment ⇒ Object
Returns the value of attribute environment.
16 17 18 |
# File 'lib/wsaa/configuration.rb', line 16 def environment @environment end |
#pkey ⇒ Object
Returns the value of attribute pkey.
16 17 18 |
# File 'lib/wsaa/configuration.rb', line 16 def pkey @pkey end |
#service ⇒ Object
Returns the value of attribute service.
16 17 18 |
# File 'lib/wsaa/configuration.rb', line 16 def service @service end |
Instance Method Details
#endpoint ⇒ String
Returns the WSAA endpoint URL for the current environment.
31 32 33 34 35 |
# File 'lib/wsaa/configuration.rb', line 31 def endpoint ENDPOINTS.fetch(environment) do raise ConfigurationError, "Invalid environment: #{environment}. Must be :testing or :production" end end |
#validate! ⇒ true
Validates the configuration.
42 43 44 45 46 47 48 |
# File 'lib/wsaa/configuration.rb', line 42 def validate! raise ConfigurationError, "Private key path not configured" if pkey.nil? || pkey.empty? raise ConfigurationError, "Certificate path not configured" if cert.nil? || cert.empty? raise ConfigurationError, "Private key file not found: #{pkey}" unless File.exist?(pkey) raise ConfigurationError, "Certificate file not found: #{cert}" unless File.exist?(cert) true end |