nfse-carioca 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Berksfile +6 -0
  4. data/Berksfile.lock +28 -0
  5. data/README.md +1 -0
  6. data/Rakefile +3 -7
  7. data/Vagrantfile +58 -0
  8. data/lib/nfse_carioca.rb +5 -12
  9. data/lib/nfse_carioca/cancelar_nfse.rb +28 -22
  10. data/lib/nfse_carioca/client.rb +31 -0
  11. data/lib/nfse_carioca/configuration.rb +49 -7
  12. data/lib/nfse_carioca/gerar_nfse.rb +14 -23
  13. data/lib/nfse_carioca/gerar_nfse_xml.rb +49 -103
  14. data/lib/nfse_carioca/response.rb +27 -0
  15. data/lib/nfse_carioca/version.rb +2 -2
  16. data/nfse_carioca.gemspec +4 -4
  17. data/spec/fixtures/vcr_cassettes/NFSeCarioca_CancelarNFSe/_execute_/when_NFSeCarioca_rps_number_does_not_exist/returns_error_message.yml +253 -0
  18. data/spec/fixtures/vcr_cassettes/NFSeCarioca_CancelarNFSe/_execute_/when_NFSeCarioca_rps_number_does_not_exist/returns_false.yml +253 -0
  19. data/spec/fixtures/vcr_cassettes/NFSeCarioca_CancelarNFSe/_execute_/when_NFSeCarioca_rps_number_exist/returns_false.yml +238 -0
  20. data/spec/fixtures/vcr_cassettes/NFSeCarioca_GerarNFSe/_call/when_NFSeCarioca_rps_number_already_exist/responds_with_error.yml +296 -0
  21. data/spec/fixtures/vcr_cassettes/NFSeCarioca_GerarNFSe/_call/when_NFSeCarioca_rps_number_already_exist/responds_with_message_error_E10_.yml +296 -0
  22. data/spec/fixtures/vcr_cassettes/NFSeCarioca_GerarNFSe/_call/when_NFSeCarioca_rps_number_does_not_exist_yet/generates_NFSeCarioca.yml +340 -0
  23. data/spec/lib/nfse_carioca/cancelar_nfse_spec.rb +13 -21
  24. data/spec/lib/nfse_carioca/configuration_spec.rb +26 -26
  25. data/spec/lib/nfse_carioca/gerar_nfse_spec.rb +31 -34
  26. data/spec/spec_helper.rb +7 -0
  27. metadata +40 -38
  28. data/CHANGELOG.md +0 -7
  29. data/CONTRIBUTING.md +0 -35
  30. data/lib/nfse_carioca/cancelar_nfse_xml.rb +0 -31
  31. data/lib/nfse_carioca/models/address.rb +0 -13
  32. data/lib/nfse_carioca/models/customer.rb +0 -15
  33. data/lib/nfse_carioca/models/invoice.rb +0 -14
  34. data/lib/nfse_carioca/models/provider.rb +0 -9
  35. data/lib/nfse_carioca/nota_carioca_client.rb +0 -31
  36. data/lib/nfse_carioca/nota_carioca_response.rb +0 -20
@@ -1,31 +0,0 @@
1
- module NFSeCarioca
2
- class CancelarNFSeXML
3
- include Virtus.model
4
-
5
- SERVICO_CODIGO_MUNICIPIO = {
6
- RIO_DE_JANEIRO: "3304557"
7
- }
8
-
9
- attribute :nf_number, String
10
- attribute :cnpj, String
11
- attribute :inscricao_municipal, String
12
-
13
- def to_xml
14
- xml = Builder::XmlMarkup.new(indent: 2)
15
- xml.instruct!
16
- xml.tag!("CancelarNfseEnvio", xmlns: "http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd") do |xml|
17
- xml.tag!("Pedido", xmlns: "http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd") do |xml|
18
- xml.tag!("InfPedidoCancelamento", Id: "Cancelamento_NF#{nf_number}") do |xml|
19
- xml.tag!("IdentificacaoNfse") do |xml|
20
- xml.tag!("Numero", nf_number)
21
- xml.tag!("Cnpj", cnpj)
22
- xml.tag!("InscricaoMunicipal", inscricao_municipal)
23
- xml.tag!("CodigoMunicipio", SERVICO_CODIGO_MUNICIPIO[:RIO_DE_JANEIRO])
24
- end
25
- xml.tag!("CodigoCancelamento", "0")
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,13 +0,0 @@
1
- module NFSeCarioca
2
- class Address
3
- include Virtus.model
4
-
5
- attribute :street, String
6
- attribute :number, String
7
- attribute :complement, String
8
- attribute :neighborhood, String
9
- attribute :city_ibge_code, String
10
- attribute :state_code, String
11
- attribute :zipcode, String
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- require "nfse_carioca/models/address"
2
-
3
- module NFSeCarioca
4
- class Customer
5
- include Virtus.model
6
-
7
- attribute :kind, String
8
- attribute :code, String
9
- attribute :full_name, String
10
- attribute :phone_number, String
11
- attribute :email, String
12
- attribute :address, Address
13
-
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- require "nfse_carioca/models/provider"
2
- require "nfse_carioca/models/customer"
3
-
4
- module NFSeCarioca
5
- class Invoice
6
- include Virtus.model
7
-
8
- attribute :identification_number, String
9
- attribute :description, String
10
- attribute :provider, Provider
11
- attribute :customer, Customer
12
-
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- module NFSeCarioca
2
- class Provider
3
- include Virtus.model
4
-
5
- attribute :cnpj, String
6
- attribute :inscricao_municipal, String
7
-
8
- end
9
- end
@@ -1,31 +0,0 @@
1
- require "savon"
2
-
3
- module NFSeCarioca
4
- class NotaCariocaClient
5
-
6
- def call(method, message)
7
- client.call(method, message: { inputXML: message })
8
- rescue Savon::HTTPError => e
9
- p e
10
- end
11
-
12
- def client
13
- @client ||= Savon.client({
14
- wsdl: NFSeCarioca.nota_carioca_wsdl_url,
15
- env_namespace: :soap,
16
- namespace_identifier: nil,
17
- element_form_default: :unqualified,
18
- ssl_verify_mode: :none,
19
- ssl_version: :SSLv3,
20
- ssl_cert_file: NFSeCarioca.cert_pem_path,
21
- ssl_cert_key_file: NFSeCarioca.cert_key_pem_path,
22
- ssl_ca_cert_file: NFSeCarioca.ca_cert_pem_path,
23
- ssl_cert_key_password: NFSeCarioca.ssl_cert_key_password,
24
- log_level: :debug,
25
- log: true,
26
- open_timeout: 120,
27
- read_timeout: 120
28
- })
29
- end
30
- end
31
- end
@@ -1,20 +0,0 @@
1
- module NFSeCarioca
2
- class NotaCariocaResponse
3
-
4
- def initialize(response)
5
- @response= response
6
- end
7
-
8
- def response_http_status
9
- @response.http.code
10
- end
11
-
12
- def raw_response_soap_envelope
13
- @response.xml
14
- end
15
-
16
- def nota_carioca_xml
17
- @nota_carioca_xml ||= Hash.from_xml(output_xml)
18
- end
19
- end
20
- end