Class: Nfcom::Configuration
- Inherits:
-
Object
- Object
- Nfcom::Configuration
- Defined in:
- lib/nfcom/configuration.rb
Constant Summary collapse
- AMBIENTES =
{ homologacao: 2, producao: 1 }.freeze
- ESTADOS =
{ 'AC' => '12', 'AL' => '27', 'AP' => '16', 'AM' => '13', 'BA' => '29', 'CE' => '23', 'DF' => '53', 'ES' => '32', 'GO' => '52', 'MA' => '21', 'MT' => '51', 'MS' => '50', 'MG' => '31', 'PA' => '15', 'PB' => '25', 'PR' => '41', 'PE' => '26', 'PI' => '22', 'RJ' => '33', 'RN' => '24', 'RS' => '43', 'RO' => '11', 'RR' => '14', 'SC' => '42', 'SP' => '35', 'SE' => '28', 'TO' => '17' }.freeze
Instance Attribute Summary collapse
-
#ambiente ⇒ Object
Configurações básicas.
-
#certificado_path ⇒ Object
Certificado digital.
-
#certificado_senha ⇒ Object
Certificado digital.
-
#cnpj ⇒ Object
Dados do emitente.
-
#estado ⇒ Object
Configurações básicas.
-
#inscricao_estadual ⇒ Object
Dados do emitente.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Logging.
-
#max_tentativas ⇒ Object
Retry.
-
#numero_inicial ⇒ Object
Configurações de série e numeração.
-
#razao_social ⇒ Object
Dados do emitente.
-
#regime_tributario ⇒ Object
Dados do emitente.
-
#serie_padrao ⇒ Object
Configurações de série e numeração.
-
#tempo_espera_retry ⇒ Object
Retry.
-
#timeout ⇒ Object
Configurações básicas.
Instance Method Summary collapse
- #ambiente_codigo ⇒ Object
- #codigo_uf ⇒ Object
- #desabilitar_logs ⇒ Object
- #habilitar_logs(output = $stdout) ⇒ Object
- #homologacao? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #producao? ⇒ Boolean
- #webservice_url(servico) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nfcom/configuration.rb', line 41 def initialize @ambiente = :homologacao @estado = 'PE' @timeout = 30 @serie_padrao = 1 @numero_inicial = 1 @max_tentativas = 3 @tempo_espera_retry = 2 @log_level = :info @logger = Logger.new($stdout) @logger.level = Logger::INFO end |
Instance Attribute Details
#ambiente ⇒ Object
Configurações básicas
23 24 25 |
# File 'lib/nfcom/configuration.rb', line 23 def ambiente @ambiente end |
#certificado_path ⇒ Object
Certificado digital
26 27 28 |
# File 'lib/nfcom/configuration.rb', line 26 def certificado_path @certificado_path end |
#certificado_senha ⇒ Object
Certificado digital
26 27 28 |
# File 'lib/nfcom/configuration.rb', line 26 def certificado_senha @certificado_senha end |
#cnpj ⇒ Object
Dados do emitente
29 30 31 |
# File 'lib/nfcom/configuration.rb', line 29 def cnpj @cnpj end |
#estado ⇒ Object
Configurações básicas
23 24 25 |
# File 'lib/nfcom/configuration.rb', line 23 def estado @estado end |
#inscricao_estadual ⇒ Object
Dados do emitente
29 30 31 |
# File 'lib/nfcom/configuration.rb', line 29 def inscricao_estadual @inscricao_estadual end |
#log_level ⇒ Object
Returns the value of attribute log_level.
36 37 38 |
# File 'lib/nfcom/configuration.rb', line 36 def log_level @log_level end |
#logger ⇒ Object
Logging
35 36 37 |
# File 'lib/nfcom/configuration.rb', line 35 def logger @logger end |
#max_tentativas ⇒ Object
Retry
39 40 41 |
# File 'lib/nfcom/configuration.rb', line 39 def max_tentativas @max_tentativas end |
#numero_inicial ⇒ Object
Configurações de série e numeração
32 33 34 |
# File 'lib/nfcom/configuration.rb', line 32 def numero_inicial @numero_inicial end |
#razao_social ⇒ Object
Dados do emitente
29 30 31 |
# File 'lib/nfcom/configuration.rb', line 29 def @razao_social end |
#regime_tributario ⇒ Object
Dados do emitente
29 30 31 |
# File 'lib/nfcom/configuration.rb', line 29 def regime_tributario @regime_tributario end |
#serie_padrao ⇒ Object
Configurações de série e numeração
32 33 34 |
# File 'lib/nfcom/configuration.rb', line 32 def serie_padrao @serie_padrao end |
#tempo_espera_retry ⇒ Object
Retry
39 40 41 |
# File 'lib/nfcom/configuration.rb', line 39 def tempo_espera_retry @tempo_espera_retry end |
#timeout ⇒ Object
Configurações básicas
23 24 25 |
# File 'lib/nfcom/configuration.rb', line 23 def timeout @timeout end |
Instance Method Details
#ambiente_codigo ⇒ Object
54 55 56 |
# File 'lib/nfcom/configuration.rb', line 54 def ambiente_codigo AMBIENTES[ambiente] end |
#codigo_uf ⇒ Object
58 59 60 |
# File 'lib/nfcom/configuration.rb', line 58 def codigo_uf ESTADOS[estado] end |
#desabilitar_logs ⇒ Object
70 71 72 |
# File 'lib/nfcom/configuration.rb', line 70 def desabilitar_logs @logger = Logger.new(IO::NULL) end |
#habilitar_logs(output = $stdout) ⇒ Object
74 75 76 77 |
# File 'lib/nfcom/configuration.rb', line 74 def habilitar_logs(output = $stdout) @logger = Logger.new(output) atualizar_log_level end |
#homologacao? ⇒ Boolean
62 63 64 |
# File 'lib/nfcom/configuration.rb', line 62 def homologacao? ambiente == :homologacao end |
#producao? ⇒ Boolean
66 67 68 |
# File 'lib/nfcom/configuration.rb', line 66 def producao? ambiente == :producao end |
#webservice_url(servico) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/nfcom/configuration.rb', line 85 def webservice_url(servico) base_url = if homologacao? webservices_homologacao[estado.to_sym] else webservices_producao[estado.to_sym] end return nil unless base_url base_url[servico] end |