Class: Wsaa::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_dirObject

Returns the value of attribute cache_dir.



16
17
18
# File 'lib/wsaa/configuration.rb', line 16

def cache_dir
  @cache_dir
end

#certObject

Returns the value of attribute cert.



16
17
18
# File 'lib/wsaa/configuration.rb', line 16

def cert
  @cert
end

#environmentObject

Returns the value of attribute environment.



16
17
18
# File 'lib/wsaa/configuration.rb', line 16

def environment
  @environment
end

#pkeyObject

Returns the value of attribute pkey.



16
17
18
# File 'lib/wsaa/configuration.rb', line 16

def pkey
  @pkey
end

#serviceObject

Returns the value of attribute service.



16
17
18
# File 'lib/wsaa/configuration.rb', line 16

def service
  @service
end

Instance Method Details

#endpointString

Returns the WSAA endpoint URL for the current environment.

Returns:

  • (String)

    The endpoint URL.

Raises:



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.

Returns:

  • (true)

    If the configuration is valid.

Raises:



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