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 +4 -4
- data/CHANGELOG.md +3 -0
- data/enotas_api.gemspec +1 -1
- data/lib/enotas_api/common/entity.rb +14 -5
- data/lib/enotas_api/support/attributable.rb +14 -2
- data/lib/enotas_api/support/type_handler.rb +2 -0
- data/lib/enotas_api/v1/entities/empresa.rb +19 -19
- data/lib/enotas_api/v1/entities/empresa_configuracoes.rb +6 -6
- data/lib/enotas_api/v1/entities/empresa_endereco.rb +10 -10
- data/lib/enotas_api/v1/entities/nfs.rb +16 -7
- data/lib/enotas_api/v1/entities/nfs_cliente.rb +8 -5
- data/lib/enotas_api/v1/entities/nfs_cliente_endereco.rb +7 -7
- data/lib/enotas_api/v1/entities/nfs_dados_adicionais_email.rb +13 -0
- data/lib/enotas_api/v1/entities/nfs_servico.rb +15 -11
- data/lib/enotas_api/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f32296c352fa04f05b793c4a65c6edf503db4bf60cf216ddd1a09d6bc2529964
|
4
|
+
data.tar.gz: 9527f7fda48a0e52e5ece0bae5d76ea025d4d6477ef63d24a9823b341250ab80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 037f7ee47f22ad756483d6fb87ba6913246acdab727ee1d4312313fc6cf3e9805f51c4f663a96ca9888a957bcfa76a2894620e87e11d0632f653604daf33cc13
|
7
|
+
data.tar.gz: ee90b0c194e39fb8f75dc3b244be0fbed4bad065ddbcc522c5aecfa9e0d1114af055e5d73c88210f8231d471e1364222237b46b72c92e9345e9bedb80729fec9
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/enotas_api.gemspec
CHANGED
@@ -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('
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
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.
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
data/lib/enotas_api/version.rb
CHANGED
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:
|
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-
|
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
|
165
|
+
version: '2.6'
|
165
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
167
|
requirements:
|
167
168
|
- - ">="
|