Class: FE::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/facturacr/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/facturacr/configuration.rb', line 19

def initialize
  @environment = "development"
  @mode = :manual
  @api_username = "changeme"
  @api_password = "changeme"
  @key_path = "resources/test.p12"
  @key_password = "test123"
  @api_client_id = 'api-stag'
  @documents_endpoint = "https://api.comprobanteselectronicos.go.cr/recepcion-sandbox/v1"
  @authentication_endpoint = "https://idp.comprobanteselectronicos.go.cr/auth/realms/rut-stag/protocol/openid-connect"
end

Instance Attribute Details

#api_client_idObject

Returns the value of attribute api_client_id.



12
13
14
# File 'lib/facturacr/configuration.rb', line 12

def api_client_id
  @api_client_id
end

#api_passwordObject

Returns the value of attribute api_password.



7
8
9
# File 'lib/facturacr/configuration.rb', line 7

def api_password
  @api_password
end

#api_usernameObject

Returns the value of attribute api_username.



6
7
8
# File 'lib/facturacr/configuration.rb', line 6

def api_username
  @api_username
end

#authentication_endpointObject

Returns the value of attribute authentication_endpoint.



11
12
13
# File 'lib/facturacr/configuration.rb', line 11

def authentication_endpoint
  @authentication_endpoint
end

#documents_endpointObject

Returns the value of attribute documents_endpoint.



10
11
12
# File 'lib/facturacr/configuration.rb', line 10

def documents_endpoint
  @documents_endpoint
end

#environmentObject

Returns the value of attribute environment.



13
14
15
# File 'lib/facturacr/configuration.rb', line 13

def environment
  @environment
end

#file_pathObject

Returns the value of attribute file_path.



14
15
16
# File 'lib/facturacr/configuration.rb', line 14

def file_path
  @file_path
end

#key_passwordObject

Returns the value of attribute key_password.



9
10
11
# File 'lib/facturacr/configuration.rb', line 9

def key_password
  @key_password
end

#key_pathObject

Returns the value of attribute key_path.



8
9
10
# File 'lib/facturacr/configuration.rb', line 8

def key_path
  @key_path
end

#modeObject

Returns the value of attribute mode.



15
16
17
# File 'lib/facturacr/configuration.rb', line 15

def mode
  @mode
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/facturacr/configuration.rb', line 47

def file?
  @mode.to_sym.eql?(:file)
end

#manual?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/facturacr/configuration.rb', line 43

def manual?
  @mode.to_sym.eql?(:manual)
end

#read_config_fileObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/facturacr/configuration.rb', line 31

def read_config_file
  if file? && @file_path && File.exists?(@file_path)
    template = ERB.new(File.read(@file_path))
    result = YAML.load(template.result(binding))
    result[@environment].each do |k,v|
      if respond_to?(k)
        self.send("#{k}=",v)
      end
    end
  end
end

#version_42?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/facturacr/configuration.rb', line 51

def version_42?
  version.eql?('4.2')
end

#version_43?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/facturacr/configuration.rb', line 55

def version_43?
  version.eql?('4.3')
end