nfse_gyn 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8edeb97b674900d2d55bfe6079983a82928ce28d
4
- data.tar.gz: 9a66234db94af251416151771705d6c795c21699
3
+ metadata.gz: c710d085d453641726363fae2c007fa433709101
4
+ data.tar.gz: fe99136b5678a938524376700d459e11afe99f8e
5
5
  SHA512:
6
- metadata.gz: ad16794f0150a07fd650c15c7c0e9fd1f8164a1557a2964208bcb08289b836a480c1d3557607601fcf113522fd1983ff55dd82fc6aad3cf08dca4824ce6dd073
7
- data.tar.gz: d809f3cf8333b71cb5bd2037729f1c4bf8c8dc7e7ebaac014b4a01e424078cd97d4b42d29f0ecb139bf0b1f7d5d71d450e611513f9554fc69435734aef2c84b7
6
+ metadata.gz: 5ce801ccd98b3b7d0d597617a7c90bd455ac8ea8e19ef918b31833682cb0484763cbe7366dcfd7031c8dfe0558ac2597f076e0e448e60094003f568837a293b6
7
+ data.tar.gz: 533108f718d01033ba661f576cbf7b1f65f1efade0c8df96898cc105aae635a5037c049f58f52e6f888e94e966db451614cde270102da2537660bccb3703d0bb
@@ -46,16 +46,12 @@ module NfseGyn
46
46
  @content ||= output['ConsultarNfseRpsResposta']
47
47
  end
48
48
 
49
- def number
50
- content['CompNfse']['Nfse']['InfNfse']['Numero'] if successful?
51
- end
52
-
53
- def verification_code
54
- content['CompNfse']['Nfse']['InfNfse']['CodigoVerificacao'] if successful?
49
+ def body
50
+ content['CompNfse']
55
51
  end
56
52
 
57
53
  def error?
58
- !content['CompNfse'] || content['ListaMensagemRetorno']['MensagemRetorno']['Codigo'] != 'L000'
54
+ !body || content['ListaMensagemRetorno']['MensagemRetorno']['Codigo'] != 'L000'
59
55
  end
60
56
  end
61
57
  end
@@ -26,12 +26,8 @@ module NfseGyn
26
26
  @content ||= output['GerarNfseResposta']
27
27
  end
28
28
 
29
- def number
30
- content['ListaNfse']['CompNfse']['Nfse']['InfNfse']['Numero'] if successful?
31
- end
32
-
33
- def verification_code
34
- content['ListaNfse']['CompNfse']['Nfse']['InfNfse']['CodigoVerificacao'] if successful?
29
+ def body
30
+ content['ListaNfse']['CompNfse']
35
31
  end
36
32
 
37
33
  def error?
@@ -12,6 +12,25 @@ module NfseGyn
12
12
  !error?
13
13
  end
14
14
 
15
+ def link
16
+ <<-URL.squish
17
+ https://www2.goiania.go.gov.br/sistemas/snfse/asp/snfse00200w0.asp?inscricao=#{municipal_registration}&nota=#{number}&verificador=#{verification_code}
18
+ URL
19
+ end
20
+
21
+ def municipal_registration
22
+ p = body['Nfse']['InfNfse']['DeclaracaoPrestacaoServico']['Prestador']
23
+ p['IdentificacaoPrestador']['InscricaoMunicipal'] if successful?
24
+ end
25
+
26
+ def number
27
+ body['Nfse']['InfNfse']['Numero'] if successful?
28
+ end
29
+
30
+ def verification_code
31
+ body['Nfse']['InfNfse']['CodigoVerificacao'] if successful?
32
+ end
33
+
15
34
  def error?
16
35
  content['ListaMensagemRetorno'].present?
17
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NfseGyn
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.2'.freeze
5
5
  end
@@ -19,7 +19,7 @@ RSpec.describe NfseGyn::GerarNfse do
19
19
  end
20
20
 
21
21
  describe '#execute!' do
22
- let(:response) { File.read(fixture_file_path('xmls/valid_gerar_nfse_response.xml'))}
22
+ let(:response) { File.read(fixture_file_path('xmls/valid_gerar_nfse_response.xml')) }
23
23
  let(:xml_payload) { File.read(fixture_file_path('xmls/valid_gerar_nfse_request.xml')) }
24
24
  let(:request_payload) { "<ArquivoXML><![CDATA[#{xml_payload}]]></ArquivoXML>" }
25
25
 
@@ -28,16 +28,31 @@ RSpec.describe NfseGyn::GerarNfse do
28
28
  end
29
29
 
30
30
  context 'valid request' do
31
-
32
31
  before { savon.expects(:gerar_nfse).with(message: request_payload).returns(response) }
33
32
 
34
33
  it 'returns a valid response' do
35
34
  expect(subject.execute!).to be_successful
36
35
  end
36
+
37
+ it 'response number is equals 370' do
38
+ expect(subject.execute!.number).to eq('370')
39
+ end
40
+
41
+ it 'response verification_code is equals MB94-C3ZA' do
42
+ expect(subject.execute!.verification_code).to eq('MB94-C3ZA')
43
+ end
44
+
45
+ it 'response municipal_registration is equals 1300687' do
46
+ expect(subject.execute!.municipal_registration).to eq('1300687')
47
+ end
48
+
49
+ it 'response link is equals nf link' do
50
+ expect(subject.execute!.link).to eq('https://www2.goiania.go.gov.br/sistemas/snfse/asp/snfse00200w0.asp?inscricao=1300687&nota=370&verificador=MB94-C3ZA')
51
+ end
37
52
  end
38
53
 
39
54
  context 'invalid request' do
40
- let(:response) { File.read(fixture_file_path('xmls/invalid_gerar_nfse_response.xml'))}
55
+ let(:response) { File.read(fixture_file_path('xmls/invalid_gerar_nfse_response.xml')) }
41
56
 
42
57
  before { savon.expects(:gerar_nfse).with(message: request_payload).returns(response) }
43
58
 
@@ -53,13 +68,13 @@ RSpec.describe NfseGyn::GerarNfse do
53
68
  context 'when mock data' do
54
69
  before do
55
70
  NfseGyn.configuration.mock_mode = true
56
- allow(NfseGyn::MockGerarNfseResponse).to receive(:new).and_return("mock response")
71
+ allow(NfseGyn::MockGerarNfseResponse).to receive(:new).and_return('mock response')
57
72
  end
58
73
 
59
74
  after { NfseGyn.configuration.mock_mode = false }
60
75
 
61
76
  it 'should return a MockConsultarNfseResponse' do
62
- expect(subject.execute!).to eq("mock response")
77
+ expect(subject.execute!).to eq('mock response')
63
78
  end
64
79
  end
65
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfse_gyn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Vicente