nfe-paulistana 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +20 -17
- data/README.md +1 -1
- data/lib/nfe-paulistana.rb +8 -26
- data/lib/nfe-paulistana/gateway.rb +11 -25
- data/lib/nfe-paulistana/version.rb +1 -1
- data/nfe-paulistana.gemspec +2 -2
- metadata +10 -10
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nfe-paulistana (0.
|
5
|
-
nokogiri
|
6
|
-
savon (
|
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.
|
15
|
+
builder (3.2.2)
|
16
16
|
diff-lcs (1.1.3)
|
17
|
-
gyoku (1.
|
17
|
+
gyoku (1.1.0)
|
18
18
|
builder (>= 2.1.2)
|
19
|
-
httpi (
|
19
|
+
httpi (2.1.0)
|
20
20
|
rack
|
21
|
+
rubyntlm (~> 0.3.2)
|
21
22
|
nokogiri (1.5.9)
|
22
|
-
nori (
|
23
|
-
rack (1.
|
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
|
-
|
33
|
-
|
33
|
+
rubyntlm (0.3.4)
|
34
|
+
savon (2.3.0)
|
35
|
+
akami (~> 1.2.0)
|
34
36
|
builder (>= 2.1.2)
|
35
|
-
gyoku (
|
36
|
-
httpi (~> 0
|
37
|
-
nokogiri (>= 1.4.0)
|
38
|
-
nori (~>
|
39
|
-
wasabi (~> 2.
|
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.
|
43
|
-
|
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(
|
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
|
------------
|
data/lib/nfe-paulistana.rb
CHANGED
@@ -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.
|
23
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
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
|
-
|
26
|
-
|
27
|
-
|
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[:
|
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
|
80
|
-
response = client.
|
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.
|
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
|
94
|
-
Savon
|
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
|
data/nfe-paulistana.gemspec
CHANGED
@@ -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", "
|
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.
|
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-
|
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:
|
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:
|
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:
|
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:
|
45
|
+
version: 2.3.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: signer
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|