enotas_api 1.0.2 → 2.0.0

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
  SHA256:
3
- metadata.gz: aebce3c20a825b7d6081c72b4a656634c5c5b71ba8df4b1bbcf72d2145ca8033
4
- data.tar.gz: f613fdd47e28d4f8d0f210122b973cbfe6a92002705329b8b696195d59de8b9d
3
+ metadata.gz: f32296c352fa04f05b793c4a65c6edf503db4bf60cf216ddd1a09d6bc2529964
4
+ data.tar.gz: 9527f7fda48a0e52e5ece0bae5d76ea025d4d6477ef63d24a9823b341250ab80
5
5
  SHA512:
6
- metadata.gz: e64f6bcca0685b09aa54e652b5de4d8b4b4a48a1bcbb17180160f90b6e5b0dabf7616db592875bb878401049da3e9ce02dd5b1403e90a4a5634d816e581e7056
7
- data.tar.gz: db850da3b638d066912e421d4fe7c908f6e679dd2955ea27246ba1751f3d8c5374be87c7ddbb3b0a96130b3c9ef0dde3e49fe01dced2cc7158e691cc4e508691
6
+ metadata.gz: 037f7ee47f22ad756483d6fb87ba6913246acdab727ee1d4312313fc6cf3e9805f51c4f663a96ca9888a957bcfa76a2894620e87e11d0632f653604daf33cc13
7
+ data.tar.gz: ee90b0c194e39fb8f75dc3b244be0fbed4bad065ddbcc522c5aecfa9e0d1114af055e5d73c88210f8231d471e1364222237b46b72c92e9345e9bedb80729fec9
@@ -1,3 +1,6 @@
1
+ # 2.0.0
2
+ - [BREAK_CHANGE] Método attributes das classes entity agora renomeado para entity_attributes, porém se mantem attributes nas instancias das mesmas classes
3
+ - Adicionando suporte completo (todos os campos) a NFS-e
1
4
  # 1.0.2
2
5
  - Ajustando bug na renderização de json, que trazia o atributo inválido @attributes no json
3
6
  # 1.0.1
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Non oficial, well supported, e-notas ruby api client'
13
13
  spec.homepage = 'https://github.com/salaozen/enotas_api'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.6')
15
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.6')
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
+ require 'date'
5
+ require 'time'
4
6
  require_relative '../support/attributable'
5
7
 
6
8
  module EnotasApi
@@ -8,10 +10,10 @@ module EnotasApi
8
10
  include EnotasApi::Attributable
9
11
 
10
12
  def as_json(_options = nil)
11
- self.class.attributes.keys
12
- .map { |att| [att, json_value(att)] }
13
- .reject { |e| e[1].nil? && !attribute_changed?(e[0]) }
14
- .to_h
13
+ attributes.keys
14
+ .map { |att| [att, json_value(att)] }
15
+ .reject { |e| e[1].nil? && !attribute_changed?(e[0]) }
16
+ .to_h
15
17
  end
16
18
 
17
19
  def to_json(options = nil)
@@ -22,7 +24,14 @@ module EnotasApi
22
24
 
23
25
  def json_value(attr)
24
26
  value = send(attr)
25
- value.is_a?(EnotasApi::Entity) ? value.as_json : value
27
+ return nil if value.nil?
28
+
29
+ type = attribute_type(attr)
30
+
31
+ return value.as_json if type.is_a?(Class)
32
+ return value.to_time.utc.iso8601 if type == :datetime
33
+
34
+ value
26
35
  end
27
36
  end
28
37
  end
@@ -21,7 +21,11 @@ module EnotasApi
21
21
  end
22
22
 
23
23
  def attributes
24
- self.class.attributes
24
+ self.class.entity_attributes
25
+ end
26
+
27
+ def attribute_type(attribute)
28
+ self.class.attribute_type(attribute)
25
29
  end
26
30
 
27
31
  def set(attributes)
@@ -51,9 +55,17 @@ module EnotasApi
51
55
  end
52
56
  end
53
57
 
54
- def attributes
58
+ def attributes(map)
59
+ map.each_pair(&method(:attribute))
60
+ end
61
+
62
+ def entity_attributes
55
63
  (@attributes || {}).freeze
56
64
  end
65
+
66
+ def attribute_type(attribute)
67
+ entity_attributes[attribute.to_sym]
68
+ end
57
69
  end
58
70
  end
59
71
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bigdecimal'
4
+ require 'date'
4
5
 
5
6
  module EnotasApi
6
7
  class TypeHandler
@@ -9,6 +10,7 @@ module EnotasApi
9
10
  decimal: ->(value, _type) { value.is_a?(Float) || value.is_a?(Integer) || value.is_a?(BigDecimal) },
10
11
  integer: ->(value, _type) { value.is_a?(Integer) },
11
12
  string: ->(value, _type) { value.is_a?(String) },
13
+ datetime: ->(value, _type) { value.is_a?(DateTime) || value.is_a?(Date) },
12
14
  entity: ->(value, type) { value.is_a?(type) || value.is_a?(Hash) }
13
15
  }.freeze
14
16
 
@@ -7,25 +7,25 @@ require_relative 'empresa_configuracoes'
7
7
  module EnotasApi
8
8
  module V1
9
9
  class Empresa < EnotasApi::Entity
10
- attribute :id, :string
11
- attribute :cnpj, :string
12
- attribute :inscricaoMunicipal, :string
13
- attribute :inscricaoEstadual, :string
14
- attribute :razaoSocial, :string
15
- attribute :nomeFantasia, :string
16
- attribute :optanteSimplesNacional, :boolean
17
- attribute :email, :string
18
- attribute :telefoneComercial, :string
19
- attribute :incentivadorCultural, :boolean
20
- attribute :regimeEspecialTributacao, :string
21
- attribute :codigoServicoMunicipal, :string
22
- attribute :cnae, :string
23
- attribute :aliquotaIss, :decimal
24
- attribute :descricaoServico, :string
25
- attribute :itemListaServicoLC116, :string
26
- attribute :endereco, EnotasApi::V1::EmpresaEndereco
27
- attribute :configuracoesNFSeHomologacao, EnotasApi::V1::EmpresaConfiguracoes
28
- attribute :configuracoesNFSeProducao, EnotasApi::V1::EmpresaConfiguracoes
10
+ attributes id: :string,
11
+ cnpj: :string,
12
+ inscricaoMunicipal: :string,
13
+ inscricaoEstadual: :string,
14
+ razaoSocial: :string,
15
+ nomeFantasia: :string,
16
+ optanteSimplesNacional: :boolean,
17
+ email: :string,
18
+ telefoneComercial: :string,
19
+ incentivadorCultural: :boolean,
20
+ regimeEspecialTributacao: :string,
21
+ codigoServicoMunicipal: :string,
22
+ cnae: :string,
23
+ aliquotaIss: :decimal,
24
+ descricaoServico: :string,
25
+ itemListaServicoLC116: :string,
26
+ endereco: EmpresaEndereco,
27
+ configuracoesNFSeHomologacao: EmpresaConfiguracoes,
28
+ configuracoesNFSeProducao: EmpresaConfiguracoes
29
29
  end
30
30
  end
31
31
  end
@@ -5,12 +5,12 @@ require_relative '../../common/entity'
5
5
  module EnotasApi
6
6
  module V1
7
7
  class EmpresaConfiguracoes < EnotasApi::Entity
8
- attribute :sequencialNFe, :integer
9
- attribute :serieNFe, :string
10
- attribute :sequencialLoteNFe, :integer
11
- attribute :usuarioAcessoProvedor, :string
12
- attribute :senhaAcessoProvedor, :string
13
- attribute :tokenAcessoProvedor, :string
8
+ attributes sequencialNFe: :integer,
9
+ serieNFe: :string,
10
+ sequencialLoteNFe: :integer,
11
+ usuarioAcessoProvedor: :string,
12
+ senhaAcessoProvedor: :string,
13
+ tokenAcessoProvedor: :string
14
14
  end
15
15
  end
16
16
  end
@@ -5,16 +5,16 @@ require_relative '../../common/entity'
5
5
  module EnotasApi
6
6
  module V1
7
7
  class EmpresaEndereco < EnotasApi::Entity
8
- attribute :codigoIbgeUf, :integer
9
- attribute :codigoIbgeCidade, :integer
10
- attribute :pais, :string
11
- attribute :uf, :string
12
- attribute :cidade, :string
13
- attribute :logradouro, :string
14
- attribute :numero, :string
15
- attribute :complemento, :string
16
- attribute :bairro, :string
17
- attribute :cep, :string
8
+ attributes codigoIbgeUf: :integer,
9
+ codigoIbgeCidade: :integer,
10
+ pais: :string,
11
+ uf: :string,
12
+ cidade: :string,
13
+ logradouro: :string,
14
+ numero: :string,
15
+ complemento: :string,
16
+ bairro: :string,
17
+ cep: :string
18
18
  end
19
19
  end
20
20
  end
@@ -3,17 +3,26 @@
3
3
  require_relative '../../common/entity'
4
4
  require_relative 'nfs_cliente'
5
5
  require_relative 'nfs_servico'
6
+ require_relative 'nfs_dados_adicionais_email'
6
7
 
7
8
  module EnotasApi
8
9
  module V1
9
10
  class Nfs < EnotasApi::Entity
10
- attribute :idExterno, :string
11
- attribute :ambienteEmissao, :string
12
- attribute :enviarPorEmail, :boolean
13
- attribute :cliente, EnotasApi::V1::NfsCliente
14
- attribute :servico, EnotasApi::V1::NfsServico
15
- attribute :valorTotal, :decimal
16
- attribute :observacoes, :string
11
+ attributes idExterno: :string,
12
+ ambienteEmissao: :string,
13
+ numeroRps: :integer,
14
+ serieRps: :string,
15
+ tipo: :string,
16
+ dataCompetencia: :datetime,
17
+ enviarPorEmail: :boolean,
18
+ dadosAdicionaisEmail: NfsDadosAdicionaisEmail,
19
+ cliente: NfsCliente,
20
+ servico: NfsServico,
21
+ naturezaOperacao: :string,
22
+ deducoes: :decimal,
23
+ descontos: :decimal,
24
+ valorTotal: :decimal,
25
+ observacoes: :string
17
26
  end
18
27
  end
19
28
  end
@@ -6,11 +6,14 @@ require_relative 'nfs_cliente_endereco'
6
6
  module EnotasApi
7
7
  module V1
8
8
  class NfsCliente < EnotasApi::Entity
9
- attribute :tipoPessoa, :string
10
- attribute :nome, :string
11
- attribute :email, :string
12
- attribute :cpfCnpj, :string
13
- attribute :endereco, EnotasApi::V1::NfsClienteEndereco
9
+ attributes tipoPessoa: :string,
10
+ nome: :string,
11
+ email: :string,
12
+ cpfCnpj: :string,
13
+ inscricaoMunicipal: :string,
14
+ inscricaoEstadual: :string,
15
+ telefone: :string,
16
+ endereco: NfsClienteEndereco
14
17
  end
15
18
  end
16
19
  end
@@ -5,13 +5,13 @@ require_relative '../../common/entity'
5
5
  module EnotasApi
6
6
  module V1
7
7
  class NfsClienteEndereco < EnotasApi::Entity
8
- attribute :logradouro, :string
9
- attribute :numero, :string
10
- attribute :complemento, :string
11
- attribute :bairro, :string
12
- attribute :cep, :string
13
- attribute :uf, :string
14
- attribute :cidade, :string
8
+ attributes logradouro: :string,
9
+ numero: :string,
10
+ complemento: :string,
11
+ bairro: :string,
12
+ cep: :string,
13
+ uf: :string,
14
+ cidade: :string
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../common/entity'
4
+ require_relative 'nfs_cliente'
5
+ require_relative 'nfs_servico'
6
+
7
+ module EnotasApi
8
+ module V1
9
+ class NfsDadosAdicionaisEmail < EnotasApi::Entity
10
+ attributes outrosDestinatarios: :string
11
+ end
12
+ end
13
+ end
@@ -5,17 +5,21 @@ require_relative '../../common/entity'
5
5
  module EnotasApi
6
6
  module V1
7
7
  class NfsServico < EnotasApi::Entity
8
- attribute :descricao, :string
9
- attribute :aliquotaIss, :decimal
10
- attribute :issRetidoFonte, :boolean
11
- attribute :cnae, :string
12
- attribute :codigoServicoMunicipio, :string
13
- attribute :valorPis, :decimal
14
- attribute :valorCofins, :decimal
15
- attribute :valorCsll, :decimal
16
- attribute :valorInss, :decimal
17
- attribute :valorIr, :decimal
18
- attribute :codigoInternoServicoMunicipal, :string
8
+ attributes ufPrestacaoServico: :string,
9
+ municipioPrestacaoServico: :string,
10
+ descricao: :string,
11
+ aliquotaIss: :decimal,
12
+ issRetidoFonte: :boolean,
13
+ cnae: :string,
14
+ codigoServicoMunicipio: :string,
15
+ descricaoServicoMunicipio: :string,
16
+ itemListaServicoLC116: :string,
17
+ valorPis: :decimal,
18
+ valorCofins: :decimal,
19
+ valorCsll: :decimal,
20
+ valorInss: :decimal,
21
+ valorIr: :decimal,
22
+ codigoInternoServicoMunicipal: :string
19
23
  end
20
24
  end
21
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EnotasApi
4
- VERSION = '1.0.2'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enotas_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Bohrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-27 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -137,6 +137,7 @@ files:
137
137
  - lib/enotas_api/v1/entities/nfs.rb
138
138
  - lib/enotas_api/v1/entities/nfs_cliente.rb
139
139
  - lib/enotas_api/v1/entities/nfs_cliente_endereco.rb
140
+ - lib/enotas_api/v1/entities/nfs_dados_adicionais_email.rb
140
141
  - lib/enotas_api/v1/entities/nfs_servico.rb
141
142
  - lib/enotas_api/v1/habilitar_empresa.rb
142
143
  - lib/enotas_api/v1/incluir_atualizar_empresa.rb
@@ -159,9 +160,9 @@ require_paths:
159
160
  - lib
160
161
  required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - ">="
163
+ - - "~>"
163
164
  - !ruby/object:Gem::Version
164
- version: 2.6.6
165
+ version: '2.6'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
168
  - - ">="