nfe-paulistana 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nfe-paulistana (0.5.0)
5
- nokogiri
6
- savon (= 0.9.9)
4
+ nfe-paulistana (1.0.0)
5
+ nokogiri (= 1.5.9)
6
+ savon (~> 2.3.0)
7
7
  signer
8
8
 
9
9
  GEM
@@ -12,15 +12,16 @@ GEM
12
12
  akami (1.2.0)
13
13
  gyoku (>= 0.4.0)
14
14
  nokogiri (>= 1.4.0)
15
- builder (3.0.4)
15
+ builder (3.2.2)
16
16
  diff-lcs (1.1.3)
17
- gyoku (1.0.0)
17
+ gyoku (1.1.0)
18
18
  builder (>= 2.1.2)
19
- httpi (0.9.7)
19
+ httpi (2.1.0)
20
20
  rack
21
+ rubyntlm (~> 0.3.2)
21
22
  nokogiri (1.5.9)
22
- nori (1.1.5)
23
- rack (1.4.5)
23
+ nori (2.3.0)
24
+ rack (1.5.2)
24
25
  rspec (2.10.0)
25
26
  rspec-core (~> 2.10.0)
26
27
  rspec-expectations (~> 2.10.0)
@@ -29,18 +30,20 @@ GEM
29
30
  rspec-expectations (2.10.0)
30
31
  diff-lcs (~> 1.1.3)
31
32
  rspec-mocks (2.10.1)
32
- savon (0.9.9)
33
- akami (~> 1.0)
33
+ rubyntlm (0.3.4)
34
+ savon (2.3.0)
35
+ akami (~> 1.2.0)
34
36
  builder (>= 2.1.2)
35
- gyoku (>= 0.4.0)
36
- httpi (~> 0.9)
37
- nokogiri (>= 1.4.0)
38
- nori (~> 1.1)
39
- wasabi (~> 2.1)
37
+ gyoku (~> 1.1.0)
38
+ httpi (~> 2.1.0)
39
+ nokogiri (>= 1.4.0, < 1.6)
40
+ nori (~> 2.3.0)
41
+ wasabi (~> 3.2.0)
40
42
  signer (1.1.1)
41
43
  nokogiri (>= 1.5.1)
42
- wasabi (2.3.0)
43
- nokogiri (>= 1.4.0)
44
+ wasabi (3.2.0)
45
+ httpi (~> 2.0)
46
+ nokogiri (>= 1.4.0, < 1.6)
44
47
 
45
48
  PLATFORMS
46
49
  ruby
data/README.md CHANGED
@@ -4,7 +4,7 @@ Nota Fiscal Paulistana
4
4
  Instanciando o Gateway
5
5
  --------------------
6
6
 
7
- gateway = NfePaulistana::Gateway.new(cert_path: "path/to/certificate.p12", cert_pass: "password")
7
+ gateway = NfePaulistana::Gateway.new(ssl_cert_p12_path: "path/to/certificate.p12", ssl_cert_path: "path/to/certificate.pem", ssl_key_path: "path/to/key.pem", ssl_cert_pass: "password")
8
8
 
9
9
  Metodos
10
10
  ------------
@@ -9,27 +9,21 @@ require "savon"
9
9
 
10
10
  module NfePaulistana
11
11
  WSDL = 'https://nfe.prefeitura.sp.gov.br/ws/lotenfe.asmx?wsdl'
12
- Savon.configure do |config|
13
- config.soap_version = 2
14
- end
15
- Savon.env_namespace = :soap
16
12
 
17
13
  def self.enviar(data = {})
18
14
  certificado = OpenSSL::PKCS12.new(File.read(data[:cert_path]), data[:cert_pass])
19
15
  client = get_client(certificado)
20
16
 
21
17
  begin
22
- response = client.request(:envio_rps) do |soap|
23
- soap.input = [
18
+ response = client.call(:envio_rps, message: {
19
+ input: [
24
20
  "EnvioRPSRequest",
25
21
  {"xmlns" => "http://www.prefeitura.sp.gov.br/nfe"}
26
- ]
27
-
28
- soap.body = XmlBuilder.new.xml_for(:envio_rps, data, certificado)
29
-
30
- soap.version = 2
31
- end
32
- Response.new(xml: response.to_hash[:envio_rps_response][:retorno_xml], method: :envio_rps_response)
22
+ ],
23
+ body: XmlBuilder.new.xml_for(:envio_rps, data, certificado),
24
+ version: 2
25
+ })
26
+ Response.new(xml: response.hash[:envio_rps_response][:retorno_xml], method: :envio_rps_response)
33
27
  rescue Savon::Error => error
34
28
  end
35
29
  end
@@ -37,19 +31,7 @@ module NfePaulistana
37
31
  private
38
32
 
39
33
  def get_client(certificado)
40
- client = Savon::Client.new do |wsdl, http|
41
- wsdl.document = WSDL
42
- # http.auth.ssl.cert_key_file = "/Users/patricknegri/Desenvolvimento/Certificado-Iugu-Chave.pem"
43
- # http.auth.ssl.cert_file = "/Users/patricknegri/Desenvolvimento/Certificado-Iugu.pem"
44
- http.auth.ssl.cert_key = certificado.key
45
- http.auth.ssl.cert = certificado.certificate
46
- http.auth.ssl.verify_mode = :peer
47
-
48
- # http.ssl_client_auth( :cert => @certificado, :key => @certificado.key, :verify_mode => OpenSSL::SSL::VERIFY_NONE )
49
- # http.auth.ssl.cert = @certificado
50
- # http.auth.ssl.key = @certificado.key
51
- # http.auth.ssl.verify_mode = :none
52
- end
34
+ Savon.client(soap_version: 2, env_namespace: :soap, ssl_verify_mode: :peer, ssl_cert_file: certificado.certificate, ssl_cert_key_file: certificado.key, wsdl: WSDL)
53
35
  end
54
36
 
55
37
  end
@@ -2,10 +2,6 @@ require 'savon'
2
2
 
3
3
  module NfePaulistana
4
4
  class Gateway
5
- Savon.configure do |config|
6
- config.soap_version = 2
7
- end
8
- Savon.env_namespace = :soap
9
5
 
10
6
  METHODS = {
11
7
  envio_rps: "EnvioRPSRequest",
@@ -22,9 +18,11 @@ module NfePaulistana
22
18
 
23
19
  def initialize(options = {})
24
20
  @options = {
25
- cert_path: "",
26
- cert_pass: "",
27
- wdsl: 'https://nfe.prefeitura.sp.gov.br/ws/lotenfe.asmx?wsdl'
21
+ ssl_cert_p12_path: "",
22
+ ssl_cert_path: "",
23
+ ssl_key_path: "",
24
+ ssl_cert_pass: "",
25
+ wsdl: 'https://nfe.prefeitura.sp.gov.br/ws/lotenfe.asmx?wsdl'
28
26
  }.merge(options)
29
27
  end
30
28
 
@@ -71,32 +69,20 @@ module NfePaulistana
71
69
  private
72
70
 
73
71
  def certificate
74
- OpenSSL::PKCS12.new(File.read(@options[:cert_path]), @options[:cert_pass])
72
+ OpenSSL::PKCS12.new(File.read(@options[:ssl_cert_p12_path]), @options[:ssl_cert_pass])
75
73
  end
76
74
 
77
75
  def request(method, data = {})
78
76
  certificado = certificate
79
- client = get_client(certificado)
80
- response = client.request(method) do |soap|
81
- soap.input = [
82
- METHODS[method],
83
- {"xmlns" => "http://www.prefeitura.sp.gov.br/nfe"}
84
- ]
85
- soap.body = XmlBuilder.new.xml_for(method, data, certificado)
86
- soap.version = 2
87
- end
77
+ client = get_client
78
+ response = client.call(method, message: XmlBuilder.new.xml_for(method, data, certificado))
88
79
  method_response = (method.to_s + "_response").to_sym
89
- Response.new(xml: response.to_hash[method_response][:retorno_xml], method: method)
80
+ Response.new(xml: response.hash[:envelope][:body][method_response][:retorno_xml], method: method)
90
81
  rescue Savon::Error => error
91
82
  end
92
83
 
93
- def get_client(certificado)
94
- Savon::Client.new do |wsdl, http|
95
- wsdl.document = @options[:wdsl]
96
- http.auth.ssl.cert_key = certificado.key
97
- http.auth.ssl.cert = certificado.certificate
98
- http.auth.ssl.verify_mode = :peer
99
- end
84
+ def get_client
85
+ Savon.client(soap_version: 2, env_namespace: :soap, ssl_verify_mode: :peer, ssl_cert_file: @options[:ssl_cert_path], ssl_cert_key_file: @options[:ssl_key_path], ssl_cert_key_password: @options[:ssl_cert_pass], wsdl: @options[:wsdl], env_namespace: :soap, namespace_identifier: nil)
100
86
  end
101
87
  end
102
88
  end
@@ -1,3 +1,3 @@
1
1
  module NfePaulistana
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  # specify any dependencies here; for example:
22
- s.add_dependency "nokogiri"
23
- s.add_dependency "savon", "0.9.9"
22
+ s.add_dependency "nokogiri", "1.5.9"
23
+ s.add_dependency "savon", "~> 2.3.0"
24
24
  s.add_dependency "signer"
25
25
  s.add_development_dependency "rspec"
26
26
  # s.add_runtime_dependency "rest-client"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfe-paulistana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.5.9
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 1.5.9
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: savon
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - '='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.9.9
37
+ version: 2.3.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - '='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.9.9
45
+ version: 2.3.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: signer
48
48
  requirement: !ruby/object:Gem::Requirement