enotas_api 0.1.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 +7 -0
- data/.editorconfig +12 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +69 -0
- data/LICENSE.txt +21 -0
- data/README.md +151 -0
- data/Rakefile +20 -0
- data/enotas_api.gemspec +35 -0
- data/lib/enotas_api.rb +6 -0
- data/lib/enotas_api/common/entity.rb +29 -0
- data/lib/enotas_api/common/error.rb +6 -0
- data/lib/enotas_api/common/request.rb +79 -0
- data/lib/enotas_api/common/result.rb +45 -0
- data/lib/enotas_api/configuration.rb +47 -0
- data/lib/enotas_api/request_provider.rb +51 -0
- data/lib/enotas_api/support/conversion_helper.rb +31 -0
- data/lib/enotas_api/support/dynamic_attributes.rb +56 -0
- data/lib/enotas_api/support/encoding_helper.rb +20 -0
- data/lib/enotas_api/support/filterable.rb +26 -0
- data/lib/enotas_api/support/paginable.rb +17 -0
- data/lib/enotas_api/support/searchable.rb +25 -0
- data/lib/enotas_api/support/sortable.rb +28 -0
- data/lib/enotas_api/v1/consultar_caracteristicas_prefeitura.rb +18 -0
- data/lib/enotas_api/v1/consultar_cidades_servico_municipal_unificado.rb +15 -0
- data/lib/enotas_api/v1/consultar_empresa.rb +18 -0
- data/lib/enotas_api/v1/consultar_servicos_municipais.rb +22 -0
- data/lib/enotas_api/v1/entities/empresa.rb +28 -0
- data/lib/enotas_api/v1/entities/empresa_configuracoes.rb +14 -0
- data/lib/enotas_api/v1/entities/endereco.rb +18 -0
- data/lib/enotas_api/v1/listar_empresas.rb +17 -0
- data/lib/enotas_api/version.rb +5 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13a5351ba686d3a3210dad5388240d5cd7f6ba666bf0d5a1a91c7d9e77236695
|
4
|
+
data.tar.gz: 3586d0c17bc0088e6dc3de95d1832b0b828551f717db0b84ffebe8015757d13a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64e30fef619fbbed94af1d424312e812ad67b75232cef877891d60eefbb65cedcd00162f097fcb74516f22de1bd0c1017413f0d1e09a6bbedd0acda35b474770
|
7
|
+
data.tar.gz: 4abbb3a41c1585e7f74056e903860313fbc65703611f3129820619d2417ab0d3744539f2b10d364d3595f1d0eff4ed7669b97750f09d887bd70fb605e0695cb1
|
data/.editorconfig
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
2
|
+
|
3
|
+
# top-most EditorConfig file
|
4
|
+
root = true
|
5
|
+
|
6
|
+
# Unix-style newlines with a newline ending every file
|
7
|
+
[*]
|
8
|
+
charset = utf-8
|
9
|
+
end_of_line = lf
|
10
|
+
insert_final_newline = true
|
11
|
+
indent_style = space
|
12
|
+
indent_size = 2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
Exclude:
|
5
|
+
- sample.rb
|
6
|
+
NewCops: enable
|
7
|
+
UseCache: true
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- spec/**/*.rb
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 150
|
13
|
+
Naming/MethodParameterName:
|
14
|
+
Enabled: false
|
15
|
+
RSpec/ExampleLength:
|
16
|
+
Max: 15
|
17
|
+
RSpec/FilePath:
|
18
|
+
Enabled: false
|
19
|
+
RSpec/MultipleExpectations:
|
20
|
+
Enabled: false
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
enotas_api
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nbluisrs@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
enotas_api (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.7.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
11
|
+
ast (2.4.1)
|
12
|
+
crack (0.4.4)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
hashdiff (1.0.1)
|
15
|
+
parallel (1.20.0)
|
16
|
+
parser (2.7.2.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
public_suffix (4.0.6)
|
19
|
+
rainbow (3.0.0)
|
20
|
+
rake (13.0.1)
|
21
|
+
regexp_parser (1.8.2)
|
22
|
+
rexml (3.2.4)
|
23
|
+
rspec (3.10.0)
|
24
|
+
rspec-core (~> 3.10.0)
|
25
|
+
rspec-expectations (~> 3.10.0)
|
26
|
+
rspec-mocks (~> 3.10.0)
|
27
|
+
rspec-core (3.10.0)
|
28
|
+
rspec-support (~> 3.10.0)
|
29
|
+
rspec-expectations (3.10.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-mocks (3.10.0)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.0)
|
36
|
+
rubocop (1.3.1)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 2.7.1.5)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8)
|
41
|
+
rexml
|
42
|
+
rubocop-ast (>= 1.1.1)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
45
|
+
rubocop-ast (1.1.1)
|
46
|
+
parser (>= 2.7.1.5)
|
47
|
+
rubocop-rspec (2.0.0)
|
48
|
+
rubocop (~> 1.0)
|
49
|
+
rubocop-ast (>= 1.1.0)
|
50
|
+
ruby-progressbar (1.10.1)
|
51
|
+
unicode-display_width (1.7.0)
|
52
|
+
webmock (3.10.0)
|
53
|
+
addressable (>= 2.3.6)
|
54
|
+
crack (>= 0.3.2)
|
55
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
enotas_api!
|
62
|
+
rake (~> 13.0)
|
63
|
+
rspec (~> 3.10)
|
64
|
+
rubocop (~> 1.3)
|
65
|
+
rubocop-rspec (~> 2.0)
|
66
|
+
webmock (~> 3.10)
|
67
|
+
|
68
|
+
BUNDLED WITH
|
69
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Eduardo Bohrer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# EnotasApi (WORK IN PROGRESS)
|
2
|
+
*enotas_api* é um cliente ruby para a [API](https://docs.enotasgw.com.br/reference) do [e-notas](https://enotas.com.br/).
|
3
|
+
|
4
|
+
Não oficial, porém com design simples e suportada com carinho por [@salaozen](https://github.com/salaozen).
|
5
|
+
|
6
|
+
## English Readers
|
7
|
+
*enotas_api* is a ruby api client for [e-notas](https://enotas.com.br/) [API](https://docs.enotasgw.com.br/reference).
|
8
|
+
|
9
|
+
Non oficial, but well supported with love by [@salaozen](https://github.com/salaozen).
|
10
|
+
|
11
|
+
Because e-notas api is entire in portuguese, the code and documentation from here will also be. Sorry about that. :D
|
12
|
+
|
13
|
+
## Dependencias
|
14
|
+
EnotasApi não depende de nenhuma Gem externa para executar, (aloha dependency hell).
|
15
|
+
Porém implementamos utilizamos a versão que ruby que temos em produção atualmente que é `~> ruby 2.6.6`.
|
16
|
+
Se tiver interesse em fazer backport para versões anteriores, não deixe de fazer seu comentário ou abrir um PR.
|
17
|
+
|
18
|
+
## Instalação
|
19
|
+
|
20
|
+
Adicione ao seu Gemfile
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'enotas_api'
|
24
|
+
```
|
25
|
+
|
26
|
+
E então execute:
|
27
|
+
```sh
|
28
|
+
$ bundle install
|
29
|
+
```
|
30
|
+
Ou instale você mesmo com:
|
31
|
+
```sh
|
32
|
+
$ gem install enotas_api
|
33
|
+
```
|
34
|
+
|
35
|
+
## Utilização (WIP)
|
36
|
+
|
37
|
+
Primeiro é necessário configurar o `EnotasApi`
|
38
|
+
```ruby
|
39
|
+
EnotasApi::Configuration.configure(api_key: '<sua api key>')
|
40
|
+
```
|
41
|
+
Você pode ver como conseguir sua API-KEY na [documentação do e-notas](https://docs.enotasgw.com.br/docs/como-obter-a-sua-api-key).
|
42
|
+
|
43
|
+
### Conceitos
|
44
|
+
Enotas-API é dividida da mesma forma como os endpoints do e-notas para facilitar o uso e o entendimento da relação de nossa implementação com os endpoints documentos.
|
45
|
+
Portanto para cada endpoint disponíveis há um objeto em EnotasApi para.
|
46
|
+
|
47
|
+
### Alguns exemplos:
|
48
|
+
|
49
|
+
Este é um exemplo de uma consulta simples
|
50
|
+
```ruby
|
51
|
+
result = EnotasApi::V1::ConsultarCaracteristicasPrefeitura.new(codigo_ibge_cidade).call
|
52
|
+
result # é um objeto com todos os atributos retornados pela api do e-notas
|
53
|
+
result.tipoAutenticacao # = 1
|
54
|
+
result.helpTipoAutenticacao.certificadoDigital # = "Sua prefeitura exige a utilização de certificado digital, portanto, inclua aqui o arquivo de seu certificado A1."
|
55
|
+
```
|
56
|
+
|
57
|
+
Um exemplo um pouco mais complexo onde se pode utilizar os recursos de filtro, ordenação e paginação suportados pela API.
|
58
|
+
```ruby
|
59
|
+
result = EnotasApi::V1::ListarEmpresas.new.search_by_nome_fantasia('nome_fantasia').sort_by_cidade.page(number: 10, size: 30).call
|
60
|
+
result.totalRecords # = 10
|
61
|
+
result.data.first.razaoSocial # = "Razão Social"
|
62
|
+
```
|
63
|
+
|
64
|
+
Todos os objetos lhe permitem também saber a URL e o json retornado pela API
|
65
|
+
```ruby
|
66
|
+
instance = EnotasApi::V1::ConsultarCaracteristicasPrefeitura.new(123)
|
67
|
+
instance.to_url # = "https://api.enotasgw.com.br/v1/estados/cidades/123/provedor"
|
68
|
+
result = instance.call
|
69
|
+
result.to_json # = <JSON retornado pela API do e-notas>
|
70
|
+
```
|
71
|
+
|
72
|
+
### Lista de objetos disponiveis
|
73
|
+
```ruby
|
74
|
+
EnotasApi::V1::ConsultarCaracteristicasPrefeitura.new(codigo_ibge_cidade)
|
75
|
+
|
76
|
+
EnotasApi::V1::ConsultarCidadesServicioMunicipalUnificado.new
|
77
|
+
|
78
|
+
EnotasApi::V1::ConsultarEmpresa.new(id)
|
79
|
+
|
80
|
+
EnotasApi::V1::ConsultarServicosMunicipais.new(uf, nome_cidade)
|
81
|
+
|
82
|
+
EnotasApi::V1::ListarEmpresas.new
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
## Endpoints suportados (marcados com X) e em desenvolvimento (sem marcação)
|
87
|
+
API - NFS-e (V1) - [Documentação](https://docs.enotasgw.com.br/reference)
|
88
|
+
- [x] Empresa: Consultar Empresa
|
89
|
+
- [x] Empresa: Listar Empresas
|
90
|
+
- [ ] Empresa: Incluir / Atualizar Empresa
|
91
|
+
- [ ] Empresa: Vincular Certificado
|
92
|
+
- [ ] Empresa: Vincular Logotipo
|
93
|
+
- [ ] Empresa: Desabilitar Empresa
|
94
|
+
- [ ] Empresa: Habilitar Empresa
|
95
|
+
- [ ] NFS-E: Listar Notas Fiscais
|
96
|
+
- [ ] NFS-E: Consultar pelo ID do Gateway
|
97
|
+
- [ ] NFS-E: Consultar pelo Id Externo
|
98
|
+
- [ ] NFS-E: Download XML
|
99
|
+
- [ ] NFS-E: Download XML (IdExterno)
|
100
|
+
- [ ] NFS-E: Download PDF
|
101
|
+
- [ ] NFS-E: Download PDF (IdExterno)
|
102
|
+
- [ ] NFS-E: Emissão de Nota Fiscal
|
103
|
+
- [ ] NFS-E: Cancelar
|
104
|
+
- [ ] NFS-E: Cancelar (IdExterno)
|
105
|
+
- [x] API Complementar: Serviços Municipais da Cidade
|
106
|
+
- [x] API Complementar: Características da Prefeitura
|
107
|
+
- [x] API Complementar: Cidades com Serviço Municipal Unificado
|
108
|
+
|
109
|
+
API - NF-e & NFC-e (v2) - [Documentação](https://docs.enotasgw.com.br/v2/reference)
|
110
|
+
- [ ] Empresa: Incluir/Alterar Empresa
|
111
|
+
- [ ] Empresa: Vincular Certificado
|
112
|
+
- [ ] Empresa: Vincular Logotipo
|
113
|
+
- [ ] Empresa: Consultar Empresa
|
114
|
+
- [ ] Empresa: Listar Empresas
|
115
|
+
- [ ] NFC-E: Emitir Nota Fiscal
|
116
|
+
- [ ] NFC-E: Consultar Nota Fiscal
|
117
|
+
- [ ] NFC-E: Consultar XML
|
118
|
+
- [ ] NFC-E: Cancelar Nota Fiscal
|
119
|
+
- [ ] NFC-E: Consultar XML de Envio do Cancelamento
|
120
|
+
- [ ] NFC-E: Consultar XML de Retorno do Cancelamento
|
121
|
+
- [ ] NFC-E: Inutilizar Numeração
|
122
|
+
- [ ] NFC-E: Consultar Inutilização de Número da Nota Fiscal
|
123
|
+
- [ ] NFC-E: Consultar XML de Inutilização
|
124
|
+
- [ ] NF-E: Emitir Nota Fiscal
|
125
|
+
- [ ] NF-E: Consultar Nota Fiscal
|
126
|
+
- [ ] NF-E: Cancelar Nota Fiscal
|
127
|
+
- [ ] NF-E: Consultar XML de Cancelamento
|
128
|
+
- [ ] NF-E: Emitir Carta de Correção pela Chave da NF-e
|
129
|
+
- [ ] NF-E: Consultar Carta de Correção
|
130
|
+
- [ ] NF-E: Consultar XML da Carta de Correção
|
131
|
+
- [ ] NF-E: Inutilizar Numeração
|
132
|
+
- [ ] NF-E: Consultar Inutilização de Número da Nota Fiscal
|
133
|
+
- [ ] NF-E: Consultar XML de Inutilização
|
134
|
+
- [ ] S@T - SÃO PAULO: Download EXE customizado do S@T
|
135
|
+
- [ ] Consulta de nota prestada (emitida): NFS-e - Consulta de Nota Prestada (Emitida)
|
136
|
+
- [ ] Consulta de nota tomada (recebida): NF-e - Consulta de Nota Tomada (Recebida)
|
137
|
+
- [ ] Consulta de nota tomada (recebida): NF-e - Consulta de Nota Tomada sem manifestação
|
138
|
+
- [ ] Consulta de nota tomada (recebida): NFS-e - Consulta de Nota Tomada (Recebida)
|
139
|
+
- [ ] Manifestação de destinatário - NF-E: Manifestação de Destinatário (NF-e)
|
140
|
+
## Contributing
|
141
|
+
|
142
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/enotas_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/enotas_api/blob/master/CODE_OF_CONDUCT.md).
|
143
|
+
|
144
|
+
|
145
|
+
## License
|
146
|
+
|
147
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
148
|
+
|
149
|
+
## Code of Conduct
|
150
|
+
|
151
|
+
Everyone interacting in the EnotasApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/enotas_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc 'Run Rubocop'
|
9
|
+
task :rubocop do
|
10
|
+
sh 'rubocop . --auto-correct'
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Run All Resources Check'
|
14
|
+
task :check do
|
15
|
+
%w[rubocop spec].each do |task|
|
16
|
+
Rake::Task[task].execute
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: :check
|
data/enotas_api.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/enotas_api/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'enotas_api'
|
7
|
+
spec.version = EnotasApi::VERSION
|
8
|
+
spec.authors = ['Eduardo Bohrer']
|
9
|
+
spec.email = ['eduardo@salaozen.com.br']
|
10
|
+
|
11
|
+
spec.summary = 'E-notas API client'
|
12
|
+
spec.description = 'Non oficial, well supported, e-notas ruby api client'
|
13
|
+
spec.homepage = 'https://github.com/salaozen/enotas_api'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.6')
|
16
|
+
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 1.3'
|
33
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 3.10'
|
35
|
+
end
|
data/lib/enotas_api.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require_relative '../support/dynamic_attributes'
|
5
|
+
|
6
|
+
module EnotasApi
|
7
|
+
class Entity
|
8
|
+
include EnotasApi::DynamicAttributes
|
9
|
+
|
10
|
+
def apply_json(json)
|
11
|
+
json.each_pair do |field, value|
|
12
|
+
setter = "#{field}="
|
13
|
+
send(setter, value) if respond_to?(setter)
|
14
|
+
end
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def as_json(_options = {})
|
19
|
+
self.class.attributes
|
20
|
+
.map { |att| [att, try(att)] }
|
21
|
+
.select { |e| !e[1].nil? || attribute_changed?(e[0]) }
|
22
|
+
.to_h
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json(*options)
|
26
|
+
as_json.to_json(*options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'result'
|
4
|
+
require_relative '../support/encoding_helper'
|
5
|
+
require_relative '../support/filterable'
|
6
|
+
require_relative '../support/paginable'
|
7
|
+
require_relative '../support/searchable'
|
8
|
+
require_relative '../support/sortable'
|
9
|
+
|
10
|
+
module EnotasApi
|
11
|
+
class Request
|
12
|
+
include EnotasApi::EncodingHelper
|
13
|
+
include EnotasApi::Filterable
|
14
|
+
include EnotasApi::Paginable
|
15
|
+
include EnotasApi::Searchable
|
16
|
+
include EnotasApi::Sortable
|
17
|
+
|
18
|
+
attr_reader :params
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@params = {}
|
22
|
+
page if respond_to?(:page)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def call
|
27
|
+
code, content = case method
|
28
|
+
when :GET then configuration.request_provider.get(to_url)
|
29
|
+
# when :POST then configuration.request_provider.post(to_url, to_json)
|
30
|
+
else raise EnotasApi::Error, "Invalid method #{@method}"
|
31
|
+
end
|
32
|
+
|
33
|
+
result_object.new(code, content)
|
34
|
+
end
|
35
|
+
|
36
|
+
def call!
|
37
|
+
result = call
|
38
|
+
raise EnotasApi::Error, "[Request][ERROR] Status:#{result.status_code}\n#{result.to_json}" if result.error?
|
39
|
+
|
40
|
+
result
|
41
|
+
end
|
42
|
+
|
43
|
+
def method
|
44
|
+
:GET
|
45
|
+
end
|
46
|
+
|
47
|
+
def entity; end
|
48
|
+
|
49
|
+
def result_object
|
50
|
+
EnotasApi::Result
|
51
|
+
end
|
52
|
+
|
53
|
+
def uri; end
|
54
|
+
|
55
|
+
def to_url
|
56
|
+
url = "#{configuration.base_url}#{uri}"
|
57
|
+
|
58
|
+
query_params = encode_query_params(@params) if @params
|
59
|
+
url += "?#{query_params}" unless query_params&.empty?
|
60
|
+
|
61
|
+
url
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_json(*_args)
|
65
|
+
@entity&.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
def param(name, value)
|
69
|
+
@params[name] = value
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def configuration
|
76
|
+
EnotasApi::Configuration.current
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
class Result
|
7
|
+
attr_reader :status_code
|
8
|
+
|
9
|
+
def initialize(status_code, json)
|
10
|
+
@status_code = status_code
|
11
|
+
@data = JSON.parse(json)
|
12
|
+
end
|
13
|
+
|
14
|
+
def success?
|
15
|
+
@status_code.between?(200, 299)
|
16
|
+
end
|
17
|
+
|
18
|
+
def error?
|
19
|
+
!success?
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*_args)
|
23
|
+
@data.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
def respond_to_missing?(field, _include_private)
|
27
|
+
return true if @data.key?(field.to_s)
|
28
|
+
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(field, *_args)
|
33
|
+
if @data.key?(field.to_s)
|
34
|
+
value = @data[field.to_s]
|
35
|
+
|
36
|
+
return case value
|
37
|
+
when Array then value.map { |v| EnotasApi::Result.new(@status_code, v.to_json) }
|
38
|
+
when Hash then EnotasApi::Result.new(@status_code, value.to_json)
|
39
|
+
else value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
require 'logger'
|
5
|
+
require_relative 'request_provider'
|
6
|
+
|
7
|
+
module EnotasApi
|
8
|
+
class Configuration
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
NO_CONFIGURATION_ERROR = 'It\'s necessary to configure EnotasApi before to call any API method \n' \
|
12
|
+
'Please configure using EnotasApi::Configuration.configure(api_key: \'your api key\')'
|
13
|
+
|
14
|
+
attr_reader :configured, :api_key, :request_provider, :base_url, :logger
|
15
|
+
|
16
|
+
def self.configure(**kwargs)
|
17
|
+
instance.configure(kwargs)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.current
|
21
|
+
raise EnotasApi::Error, NO_CONFIGURATION_ERROR unless instance.configured
|
22
|
+
|
23
|
+
instance
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure(
|
27
|
+
api_key:,
|
28
|
+
request_provider: RequestProvider.new,
|
29
|
+
base_url: 'https://api.enotasgw.com.br',
|
30
|
+
logger: default_logger
|
31
|
+
)
|
32
|
+
@configured = true
|
33
|
+
@api_key = api_key
|
34
|
+
@request_provider = request_provider
|
35
|
+
@base_url = base_url
|
36
|
+
@logger = logger
|
37
|
+
end
|
38
|
+
|
39
|
+
def default_logger
|
40
|
+
logger = Logger.new($stdout)
|
41
|
+
logger.formatter = proc do |severity, datetime, _progname, msg|
|
42
|
+
"#{datetime} #{severity}: #{msg}\n"
|
43
|
+
end
|
44
|
+
logger
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
class RequestProvider
|
7
|
+
def get(url, headers = {})
|
8
|
+
request(Net::HTTP::Get, url, nil, headers)
|
9
|
+
end
|
10
|
+
|
11
|
+
def post(url, body, headers = {})
|
12
|
+
request(Net::HTTP::Post, url, body, headers)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def request(request_obj, url, body, headers)
|
18
|
+
track_request_time(url) do
|
19
|
+
uri = URI(url)
|
20
|
+
|
21
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
22
|
+
http.use_ssl = true if url.start_with?('https')
|
23
|
+
|
24
|
+
request = request_obj.new(uri)
|
25
|
+
configure_request_headers(request, headers)
|
26
|
+
|
27
|
+
request.body = body if body
|
28
|
+
response = http.request(request)
|
29
|
+
|
30
|
+
[response.code.to_i, response.body]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def configure_request_headers(request, custom_headers)
|
35
|
+
{
|
36
|
+
'Authorization' => "Basic #{EnotasApi::Configuration.current.api_key}",
|
37
|
+
'Content-Type' => 'application/json',
|
38
|
+
'User-Agent' => 'Enotas-Ruby-SDK',
|
39
|
+
"Accept": 'application/json'
|
40
|
+
}.merge(custom_headers).each { |key, value| request[key] = value }
|
41
|
+
end
|
42
|
+
|
43
|
+
def track_request_time(url)
|
44
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
45
|
+
value = yield
|
46
|
+
finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
47
|
+
EnotasApi::Configuration.current.logger.info("[RequestProvider] #{url} done in #{(finish - start).round(2)} seconds")
|
48
|
+
value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EnotasApi
|
4
|
+
module ConversionHelper
|
5
|
+
TYPE_HANDLERS = {
|
6
|
+
boolean: ->(value) { value == 'true' },
|
7
|
+
decimal: ->(value) { value.to_f },
|
8
|
+
entity: ->(_value) {},
|
9
|
+
integer: ->(value) { value.to_i },
|
10
|
+
string: ->(value) { value }
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
def self.support_type?(type)
|
14
|
+
!type_handler(type).nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.type_handler(type)
|
18
|
+
type = :entity if type.is_a?(Class) && type <= EnotasApi::Entity
|
19
|
+
TYPE_HANDLERS[type]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.convert_value(type, value)
|
23
|
+
return nil if value.nil?
|
24
|
+
|
25
|
+
str_value = value.to_s
|
26
|
+
return nil if type != :string && str_value.empty?
|
27
|
+
|
28
|
+
type_handler(type).call(str_value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'conversion_helper'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module DynamicAttributes
|
7
|
+
def self.included(base)
|
8
|
+
base.extend ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(**attrs)
|
12
|
+
set(attrs)
|
13
|
+
end
|
14
|
+
|
15
|
+
def attributes_changed
|
16
|
+
(@attributes_changed || []).freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
def attribute_changed?(attribute)
|
20
|
+
attributes_changed.includes?(attribute)
|
21
|
+
end
|
22
|
+
|
23
|
+
def set(attributes)
|
24
|
+
return if attributes&.empty?
|
25
|
+
|
26
|
+
attributes.each_pair do |attr, value|
|
27
|
+
method = "#{attr}="
|
28
|
+
method = attr unless respond_to?(method)
|
29
|
+
send(method, value)
|
30
|
+
end
|
31
|
+
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
module ClassMethods
|
36
|
+
def attribute(name, type)
|
37
|
+
raise EnotasApi::Error, "Type #{type} not supported" unless EnotasApi::ConversionHelper.support_type?(type)
|
38
|
+
|
39
|
+
(@attributes ||= {})[name] = type
|
40
|
+
|
41
|
+
define_method name do
|
42
|
+
instance_variable_get("@#{name}")
|
43
|
+
end
|
44
|
+
|
45
|
+
define_method "#{name}=" do |value|
|
46
|
+
instance_variable_set("@#{name}", EnotasApi::ConversionHelper.convert_value(type, value))
|
47
|
+
(@attributes_changed ||= []) << name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def attributes
|
52
|
+
(@attributes || {}).freeze
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
require 'CGI'
|
5
|
+
|
6
|
+
module EnotasApi
|
7
|
+
module EncodingHelper
|
8
|
+
def url_encode(value)
|
9
|
+
ERB::Util.url_encode(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def query_encode(value)
|
13
|
+
CGI.escape(value)
|
14
|
+
end
|
15
|
+
|
16
|
+
def encode_query_params(params)
|
17
|
+
URI.encode_www_form(params.compact { |_k, v| v.nil? })
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EnotasApi
|
4
|
+
module Filterable
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
FILTER_HANDLERS = {
|
11
|
+
eq: ->(field, value) { "#{field} eq '#{value}'" },
|
12
|
+
contains: ->(field, value) { "contains(#{field} '#{value}')" }
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def filterable(field, type)
|
16
|
+
handler = FILTER_HANDLERS[type]
|
17
|
+
|
18
|
+
raise EnotasApi::Error, "Undefined filter type '#{type}', valid values are #{FILTER_HANDLERS.keys}" unless handler
|
19
|
+
|
20
|
+
define_method "#{field}_#{type}" do |value|
|
21
|
+
param(:filter, handler.call(field, value))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EnotasApi
|
4
|
+
module Paginable
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def paginable
|
11
|
+
define_method :page do |number: 0, size: 150|
|
12
|
+
param(:pageNumber, number).param(:pageSize, size)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EnotasApi
|
4
|
+
module Searchable
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def searchable(fields)
|
11
|
+
define_method :search do |field, value|
|
12
|
+
raise EnotasApi::Error, "Unsupported search field '#{field}'" unless fields.include?(field)
|
13
|
+
|
14
|
+
param(:searchBy, field).param(:searchTerm, value)
|
15
|
+
end
|
16
|
+
|
17
|
+
fields.each do |field|
|
18
|
+
define_method "search_by_#{field}" do |value|
|
19
|
+
search(field, value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EnotasApi
|
4
|
+
module Sortable
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
DIRECTIONS = %i[asc desc].freeze
|
11
|
+
|
12
|
+
def sortable(fields)
|
13
|
+
define_method :sort do |field, direction|
|
14
|
+
raise EnotasApi::Error, "Unsupported sort field '#{field}', valid sort fields are #{fields}." unless fields.include?(field)
|
15
|
+
raise EnotasApi::Error, "Unsupported direction '#{direction}'', valid directions are #{DIRECTIONS}." unless DIRECTIONS.include?(direction)
|
16
|
+
|
17
|
+
param(:sortBy, field).param(:sortDirection, direction)
|
18
|
+
end
|
19
|
+
|
20
|
+
fields.each do |field|
|
21
|
+
define_method "sort_by_#{field}" do |direction = :asc|
|
22
|
+
sort(field, direction)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../common/request'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module V1
|
7
|
+
class ConsultarCaracteristicasPrefeitura < EnotasApi::Request
|
8
|
+
def initialize(codigo_ibge_cidade)
|
9
|
+
@codigo_ibge_cidade = codigo_ibge_cidade
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
def uri
|
14
|
+
"/v1/estados/cidades/#{url_encode(@codigo_ibge_cidade)}/provedor"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../common/request'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module V1
|
7
|
+
class ConsultarCidadesServicioMunicipalUnificado < EnotasApi::Request
|
8
|
+
paginable
|
9
|
+
|
10
|
+
def uri
|
11
|
+
'/v1/servicos/cidades'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../common/request'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module V1
|
7
|
+
class ConsultarEmpresa < EnotasApi::Request
|
8
|
+
def initialize(id)
|
9
|
+
@id = id
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
def uri
|
14
|
+
"/v1/empresas/#{url_encode(@id)}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../common/request'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module V1
|
7
|
+
class ConsultarServicosMunicipais < EnotasApi::Request
|
8
|
+
paginable
|
9
|
+
filterable :descricao, :contains
|
10
|
+
|
11
|
+
def initialize(uf, nome_cidade)
|
12
|
+
@uf = uf
|
13
|
+
@nome_cidade = nome_cidade
|
14
|
+
super()
|
15
|
+
end
|
16
|
+
|
17
|
+
def uri
|
18
|
+
"/v1/estados/#{url_encode(@uf)}/cidades/#{url_encode(@nome_cidade)}/servicos"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../common/entity'
|
4
|
+
require_relative 'endereco'
|
5
|
+
require_relative 'empresa_configuracoes'
|
6
|
+
|
7
|
+
module EnotasApi
|
8
|
+
class Empresa < EnotasApi::Entity
|
9
|
+
attribute :id, :string
|
10
|
+
attribute :cnpj, :string
|
11
|
+
attribute :inscricaoMunicipal, :string
|
12
|
+
attribute :inscricaoEstadual, :string
|
13
|
+
attribute :razaoSocial, :string
|
14
|
+
attribute :nomeFantasia, :string
|
15
|
+
attribute :optanteSimplesNacional, :boolean
|
16
|
+
attribute :email, :string
|
17
|
+
attribute :telefoneComercial, :string
|
18
|
+
attribute :incentivadorCultural, :boolean
|
19
|
+
attribute :regimeEspecialTributacao, :string
|
20
|
+
attribute :codigoServicoMunicipal, :string
|
21
|
+
attribute :cnae, :string
|
22
|
+
attribute :aliquotaIss, :decimal
|
23
|
+
attribute :descricaoServico, :string
|
24
|
+
attribute :endereco, EnotasApi::Endereco
|
25
|
+
attribute :configuracoesNFSeHomologacao, EnotasApi::EmpresaConfiguracoes
|
26
|
+
attribute :configuracoesNFSeProducao, EnotasApi::EmpresaConfiguracoes
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../common/entity'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
class EmpresaConfiguracoes < EnotasApi::Entity
|
7
|
+
attribute :sequencialNFe, :integer
|
8
|
+
attribute :serieNFe, :string
|
9
|
+
attribute :sequencialLoteNFe, :integer
|
10
|
+
attribute :usuarioAcessoProvedor, :string
|
11
|
+
attribute :senhaAcessoProvedor, :string
|
12
|
+
attribute :tokenAcessoProvedor, :string
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../common/entity'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
class Endereco < EnotasApi::Entity
|
7
|
+
attribute :codigoIbgeUf, :integer
|
8
|
+
attribute :codigoIbgeCidade, :integer
|
9
|
+
attribute :pais, :string
|
10
|
+
attribute :uf, :string
|
11
|
+
attribute :cidade, :string
|
12
|
+
attribute :logradouro, :string
|
13
|
+
attribute :numero, :string
|
14
|
+
attribute :complemento, :string
|
15
|
+
attribute :bairro, :string
|
16
|
+
attribute :cep, :string
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../common/request'
|
4
|
+
|
5
|
+
module EnotasApi
|
6
|
+
module V1
|
7
|
+
class ListarEmpresas < EnotasApi::Request
|
8
|
+
paginable
|
9
|
+
searchable %i[nome_fantasia razao_social]
|
10
|
+
sortable %i[nome_fantasia razao_social cidade data_criacao data_ultima_modificacao]
|
11
|
+
|
12
|
+
def uri
|
13
|
+
'/v1/empresas'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enotas_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eduardo Bohrer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.10'
|
83
|
+
description: Non oficial, well supported, e-notas ruby api client
|
84
|
+
email:
|
85
|
+
- eduardo@salaozen.com.br
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".editorconfig"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".ruby-gemset"
|
95
|
+
- ".ruby-version"
|
96
|
+
- CHANGELOG.md
|
97
|
+
- CODE_OF_CONDUCT.md
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.md
|
102
|
+
- Rakefile
|
103
|
+
- enotas_api.gemspec
|
104
|
+
- lib/enotas_api.rb
|
105
|
+
- lib/enotas_api/common/entity.rb
|
106
|
+
- lib/enotas_api/common/error.rb
|
107
|
+
- lib/enotas_api/common/request.rb
|
108
|
+
- lib/enotas_api/common/result.rb
|
109
|
+
- lib/enotas_api/configuration.rb
|
110
|
+
- lib/enotas_api/request_provider.rb
|
111
|
+
- lib/enotas_api/support/conversion_helper.rb
|
112
|
+
- lib/enotas_api/support/dynamic_attributes.rb
|
113
|
+
- lib/enotas_api/support/encoding_helper.rb
|
114
|
+
- lib/enotas_api/support/filterable.rb
|
115
|
+
- lib/enotas_api/support/paginable.rb
|
116
|
+
- lib/enotas_api/support/searchable.rb
|
117
|
+
- lib/enotas_api/support/sortable.rb
|
118
|
+
- lib/enotas_api/v1/consultar_caracteristicas_prefeitura.rb
|
119
|
+
- lib/enotas_api/v1/consultar_cidades_servico_municipal_unificado.rb
|
120
|
+
- lib/enotas_api/v1/consultar_empresa.rb
|
121
|
+
- lib/enotas_api/v1/consultar_servicos_municipais.rb
|
122
|
+
- lib/enotas_api/v1/entities/empresa.rb
|
123
|
+
- lib/enotas_api/v1/entities/empresa_configuracoes.rb
|
124
|
+
- lib/enotas_api/v1/entities/endereco.rb
|
125
|
+
- lib/enotas_api/v1/listar_empresas.rb
|
126
|
+
- lib/enotas_api/version.rb
|
127
|
+
homepage: https://github.com/salaozen/enotas_api
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata:
|
131
|
+
allowed_push_host: https://rubygems.org
|
132
|
+
homepage_uri: https://github.com/salaozen/enotas_api
|
133
|
+
source_code_uri: https://github.com/salaozen/enotas_api
|
134
|
+
changelog_uri: https://github.com/salaozen/enotas_api/blob/master/CHANGELOG.md
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 2.6.6
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubygems_version: 3.0.8
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: E-notas API client
|
154
|
+
test_files: []
|