Skip to content

Commit

Permalink
#4 - Refatoração de código. Adicionado arquivos de configuração para …
Browse files Browse the repository at this point in the history
…cada operação das notas fiscais facilitando a atualização para novas versões da NF-e
  • Loading branch information
Brunomm committed May 31, 2017
1 parent cab16bf commit 74171d9
Show file tree
Hide file tree
Showing 106 changed files with 5,950 additions and 8,202 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PATH
remote: .
specs:
br_nfe (2.2.0)
activemodel (~> 4)
activesupport (~> 4)
activemodel (~> 4.2)
activesupport (~> 4.2)
nokogiri (~> 1.6)
rake (~> 10)
savon (~> 2.11)
Expand Down Expand Up @@ -149,7 +149,7 @@ GEM
wasabi (~> 3.4)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
signer (1.4.3)
signer (1.5.0)
nokogiri (>= 1.5.1)
simplecov (0.10.0)
docile (~> 1.1.0)
Expand All @@ -164,7 +164,7 @@ GEM
railties (>= 3.1)
slim (~> 3.0)
slop (3.6.0)
socksify (1.7.0)
socksify (1.7.1)
sprockets (3.2.0)
rack (~> 1.0)
sprockets-rails (2.3.2)
Expand Down
4 changes: 2 additions & 2 deletions br_nfe.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = ['~> 2.1', '~> 2.2', '~> 2.3']

gem.add_dependency "rake", '~> 10'
gem.add_dependency "activesupport", '~> 4'
gem.add_dependency "activemodel", '~> 4'
gem.add_dependency "activesupport", '~> 4.2'
gem.add_dependency "activemodel", '~> 4.2'
gem.add_dependency "nokogiri", "~> 1.6"
gem.add_dependency "savon", "~> 2.11"
gem.add_dependency "signer", "~> 1.4"
Expand Down
10 changes: 9 additions & 1 deletion lib/br_nfe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,19 @@ module Build
mattr_accessor :transportador_product_class
@@transportador_product_class = BrNfe::Product::Nfe::Transporte::Transportador

def self.load_settings
settings = {}
Dir[BrNfe.root+'/lib/config/settings/**/*.{yml}'].each do |file_path|
settings.deep_merge! YAML.load(File.open(file_path)).deep_symbolize_keys!
end
settings
end
mattr_accessor :settings
@@settings = BrNfe.load_settings

def self.setup
yield self
end

######################### END CONFIGURAÇÕES #########################

include Helper
Expand Down
32 changes: 10 additions & 22 deletions lib/br_nfe/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def certificado_obrigatorio?
false
end

def ssl_request?
false
end

def env
@env ||= :production
end
Expand Down Expand Up @@ -59,8 +55,9 @@ def id_attribute?
end

# Deve conter o LINK do webservice a ser chamado
# TODO: Remover método quando reconfigurar a emissão das notas de serviço
#
def wsdl
def url_wsdl
raise "Não implementado."
end

Expand Down Expand Up @@ -167,29 +164,20 @@ def xml_version
:v1
end

# Versão da requisição SSL caso o servidor necessite de autenticação SSL
# Valores possíveis: [:TLSv1_2, :TLSv1_1, :TLSv1, :SSLv3, :SSLv23]
# Default: :SSLv3
def ssl_version
:SSLv3
def client_wsdl_params
{
wsdl: url_wsdl,
log: BrNfe.client_wsdl_log,
pretty_print_xml: BrNfe.client_wsdl_pretty_print_xml,
ssl_verify_mode: :none
}
end

# Cliente WSDL utilizado para fazer a requisição.
# Utilizando a gem savon.
# Veja mais detalhes em http://savonrb.com/version2/client.html
def client_wsdl
@client_wsdl ||= Savon.client do |global|
global.wsdl wsdl
global.log BrNfe.client_wsdl_log
global.pretty_print_xml BrNfe.client_wsdl_pretty_print_xml
global.ssl_verify_mode :none
if ssl_request?
global.ssl_version ssl_version
global.ssl_cert certificate
global.ssl_cert_key certificate_key
global.ssl_cert_key_password certificate_pkcs12_password
end
end
@client_wsdl ||= Savon.client client_wsdl_params
end

# Caso não tenha o certificate_pkcs12 salvo em arquivo, pode setar a string do certificate_pkcs12 direto pelo atributo certificate_pkcs12_value
Expand Down
2 changes: 0 additions & 2 deletions lib/br_nfe/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,5 @@ module Constants
NFE_SITUATION_CANCELED = %w[101 151 218]
NFE_SITUATION_DENIED = %w[110 205 301 302 303]
NFE_SITUATION_DRAFT = %w[105 106 108 109 137 142]


end
end
35 changes: 0 additions & 35 deletions lib/br_nfe/product/gateway/base.rb

This file was deleted.

140 changes: 0 additions & 140 deletions lib/br_nfe/product/gateway/web_service_am.rb

This file was deleted.

Loading

0 comments on commit 74171d9

Please sign in to comment.