sei 0.1.1
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/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +89 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sei.rb +29 -0
- data/lib/sei/connection.rb +22 -0
- data/lib/sei/estruturas/documento.rb +112 -0
- data/lib/sei/estruturas/procedimento.rb +64 -0
- data/lib/sei/estruturas/retorno_geracao_procedimento.rb +34 -0
- data/lib/sei/estruturas/retorno_inclusao_documento.rb +22 -0
- data/lib/sei/printer.rb +32 -0
- data/lib/sei/servico.rb +40 -0
- data/lib/sei/version.rb +3 -0
- data/sei.gemspec +40 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6d4981449630389fb3244b7a82e62fdd7464b6c
|
4
|
+
data.tar.gz: 66d39be097b455eaff3520995c7b9984853f8f68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f30897b8ad946b8bdeade93d6026a1ec896893f67d3b9de3eb1154ec71a42c2b9bf53bfc57d48e48e9edafc448e520f9804e5ee11b8505de2ab096d217cb402
|
7
|
+
data.tar.gz: c97bd07f7181fbb2825e56783767ee0ccd5a26b854a7bf7f5a9cc508c079b397b25a79e15cfc471b41ccd8eea4e2b5165c8ae986069c975f7f1fa2ab7fe22fd8
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
sei
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
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 tellesleandro@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 [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Leandro Telles
|
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,89 @@
|
|
1
|
+
# SEI!
|
2
|
+
|
3
|
+
Esta gem facilita o acesso ao webservice do SEI!. Ela possui a implementação dos métodos gerar_procedimento e incluir_documento. O retorno do webservice é automaticamente associado às classes de retorno que possuem os atributos retornados por cada serviço. Estes atributos são acessados através de assessores da classe.
|
4
|
+
|
5
|
+
## Instalação
|
6
|
+
|
7
|
+
Adicione esta linha no Gemfile da sua aplicação:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sei'
|
11
|
+
```
|
12
|
+
|
13
|
+
E execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Ou instale através do seguinte comando:
|
18
|
+
|
19
|
+
$ gem install sei
|
20
|
+
|
21
|
+
## Uso
|
22
|
+
|
23
|
+
A classe test/sei_test.rb possui casos de teste que podem ser utilizados como exemplo para chamada dos serviços.
|
24
|
+
|
25
|
+
Antes de chamar os métodos dos serviços, é necessário configurar a gem através do comando:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
|
29
|
+
Sei.configure do |config|
|
30
|
+
config.wsdl = ENV['SEI_CONFIG_WSDL']
|
31
|
+
config.follow_redirects = true
|
32
|
+
config.pretty_print_xml = true
|
33
|
+
config.sigla = ENV['SEI_CONFIG_SIGLA']
|
34
|
+
config.identificacao = ENV['SEI_CONFIG_IDENTIFICACAO']
|
35
|
+
end
|
36
|
+
|
37
|
+
```
|
38
|
+
onde
|
39
|
+
|
40
|
+
config.wsdl é o endereço do WSDL do SEI, por exemplo http[s]://[servidor php]/sei/controlador_ws.php?servico=sei';
|
41
|
+
config.follow_redirects indica para a biblioteca 'savon' que ela deve seguir as respostas 'redirect' devolvidas pelo servidor;
|
42
|
+
config.pretty_print_xml indica para a biblioteca 'savon' que as mensagens XML geradas devem ser impressas no console de forma formatada;
|
43
|
+
config.sigla é a sigla do sistema configurada no SEI, através do menu administração -> sistemas;
|
44
|
+
config.identificacao é a identificação do serviço configurado no SEI, através do menu administração -> sistemas;
|
45
|
+
|
46
|
+
Exemplo:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
|
50
|
+
procedimento = Sei::Estruturas::Procedimento.new
|
51
|
+
.id_tipo_procedimento(id_tipo_procedimento)
|
52
|
+
.especificacao(especificacao)
|
53
|
+
.assunto(codigo_estruturado, descricao)
|
54
|
+
.interessado(sigla, nome)
|
55
|
+
.observacao(observacao)
|
56
|
+
.nivel_de_acesso(nivel_de_acesso)
|
57
|
+
|
58
|
+
retorno_geracao_procedimento = Sei::Servico.gerar_procedimento(
|
59
|
+
id_unidade,
|
60
|
+
procedimento,
|
61
|
+
documentos,
|
62
|
+
procedimentos_relacionados,
|
63
|
+
unidades_envio,
|
64
|
+
manter_aberto_unidade,
|
65
|
+
enviar_email_notificacao,
|
66
|
+
data_retorno_programado,
|
67
|
+
dias_retorno_programado,
|
68
|
+
dias_uteis_retorno_programado)
|
69
|
+
|
70
|
+
puts retorno_geracao_procedimento.id_procedimento
|
71
|
+
|
72
|
+
```
|
73
|
+
|
74
|
+
## Desenvolvimento
|
75
|
+
|
76
|
+
Após checar o repositório, execute `bin/setup` para instalar as dependências. Depois, execute `rake test` para rodar os testes. É possível também executar `bin/console` para carregar o prompt interativo que permite testar a gem na linha de comando.
|
77
|
+
|
78
|
+
Para instalar esta gem na sua máquina local, execute `bundle exec rake install`. Para publicar uma nova versão, atualize o número da versão em `version.rb` e execute `bundle exec rake release`. Isto criará uma tag git para a versão. Envie (push) os commits e tags e envie (push) o arquivo `.gem` para [rubygems.org](https://rubygems.org).
|
79
|
+
|
80
|
+
## Contribuindo
|
81
|
+
|
82
|
+
Indicação de bugs e pull requests são bem-vindos no GitHub (https://github.com/tellesleandro/sei). Este projeto tem a intenção de ser seguro e incentiva a colaboração. É esperado que os contribuidores sigam o código de conduta [Contributor Covenant](http://contributor-covenant.org).
|
83
|
+
|
84
|
+
## Licença/License
|
85
|
+
|
86
|
+
Esta gem está disponível como código aberto dentro dos termos da [MIT License](http://opensource.org/licenses/MIT).
|
87
|
+
|
88
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
89
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sei"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/sei.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'base64'
|
3
|
+
require 'savon'
|
4
|
+
require 'valuable'
|
5
|
+
require 'gem_config'
|
6
|
+
|
7
|
+
require 'sei/connection'
|
8
|
+
require 'sei/printer'
|
9
|
+
require 'sei/servico'
|
10
|
+
require 'sei/version'
|
11
|
+
|
12
|
+
require 'sei/estruturas/documento'
|
13
|
+
require 'sei/estruturas/procedimento'
|
14
|
+
require 'sei/estruturas/retorno_inclusao_documento'
|
15
|
+
require 'sei/estruturas/retorno_geracao_procedimento'
|
16
|
+
|
17
|
+
module Sei
|
18
|
+
|
19
|
+
include GemConfig::Base
|
20
|
+
|
21
|
+
with_configuration do
|
22
|
+
has :wsdl, classes: String
|
23
|
+
has :follow_redirects
|
24
|
+
has :pretty_print_xml
|
25
|
+
has :sigla, classes: String
|
26
|
+
has :identificacao, classes: String
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
require "singleton"
|
4
|
+
|
5
|
+
class Connection
|
6
|
+
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def client
|
10
|
+
@client ||= Savon.client wsdl: Sei.configuration.wsdl, follow_redirects: Sei.configuration.follow_redirects,
|
11
|
+
pretty_print_xml: Sei.configuration.pretty_print_xml, convert_request_keys_to: :camelcase
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(service, message)
|
15
|
+
request = client.build_request service, message: message
|
16
|
+
Sei::Printer.xp request.body
|
17
|
+
client.call service, message
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
module Estruturas
|
4
|
+
|
5
|
+
class Documento
|
6
|
+
|
7
|
+
def tipo(tipo)
|
8
|
+
@tipo = tipo
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def id_procedimento(id_procedimento)
|
13
|
+
@id_procedimento = id_procedimento
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def id_serie(id_serie)
|
18
|
+
@id_serie = id_serie
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def numero(numero)
|
23
|
+
@numero = numero
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def data(data)
|
28
|
+
@data = data.strftime('%d/%m/%Y') rescue nil
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def descricao(descricao)
|
33
|
+
@descricao = descricao
|
34
|
+
self
|
35
|
+
end
|
36
|
+
|
37
|
+
def remetente(remetente)
|
38
|
+
@remetente = remetente
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def interessado(sigla, nome)
|
43
|
+
@interessados ||= []
|
44
|
+
@interessados << {
|
45
|
+
interessado: {
|
46
|
+
sigla: sigla,
|
47
|
+
nome: nome
|
48
|
+
}
|
49
|
+
}
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def destinatario(sigla, nome)
|
54
|
+
@destinatarios ||= []
|
55
|
+
@destinatarios << {
|
56
|
+
destinatario: {
|
57
|
+
sigla: sigla,
|
58
|
+
nome: nome
|
59
|
+
}
|
60
|
+
}
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
def observacao(observacao)
|
65
|
+
@observacao = observacao
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
69
|
+
def nome_arquivo(nome_arquivo)
|
70
|
+
@nome_arquivo = nome_arquivo
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
def conteudo(conteudo)
|
75
|
+
@conteudo = Base64.strict_encode64(conteudo)
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
def conteudo_mtom(conteudo_mtom)
|
80
|
+
@conteudo_mtom = File.read(conteudo_mtom)
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
84
|
+
def nivel_de_acesso(nivel_de_acesso)
|
85
|
+
@nivel_de_acesso = nivel_de_acesso
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_h
|
90
|
+
{
|
91
|
+
tipo: @tipo,
|
92
|
+
id_procedimento: @id_procedimento,
|
93
|
+
id_serie: @id_serie,
|
94
|
+
numero: @numero,
|
95
|
+
data: @data,
|
96
|
+
descricao: @descricao,
|
97
|
+
remetente: @remetente,
|
98
|
+
interessados: @interessados.nil? ? {} : @interessados,
|
99
|
+
destinatarios: @destinatarios.nil? ? {} : @destinatarios,
|
100
|
+
observacao: @observacao,
|
101
|
+
nome_arquivo: @nome_arquivo,
|
102
|
+
conteudo: @conteudo,
|
103
|
+
conteudo_mtom: @conteudo_mtom,
|
104
|
+
nivel_de_acesso: @nivel_de_acesso
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
module Estruturas
|
4
|
+
|
5
|
+
class Procedimento
|
6
|
+
|
7
|
+
def id_tipo_procedimento(id_tipo_procedimento)
|
8
|
+
@id_tipo_procedimento = id_tipo_procedimento
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def especificacao(especificacao)
|
13
|
+
@especificacao = especificacao
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def assunto(codigo_estruturado, descricao)
|
18
|
+
@assuntos ||= []
|
19
|
+
@assuntos << {
|
20
|
+
assunto: {
|
21
|
+
codigo_estruturado: codigo_estruturado,
|
22
|
+
descricao: descricao
|
23
|
+
}
|
24
|
+
}
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def interessado(sigla, nome)
|
29
|
+
@interessados ||= []
|
30
|
+
@interessados << {
|
31
|
+
interessado: {
|
32
|
+
sigla: sigla,
|
33
|
+
nome: nome
|
34
|
+
}
|
35
|
+
}
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def observacao(observacao)
|
40
|
+
@observacao = observacao
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def nivel_de_acesso(nivel_de_acesso)
|
45
|
+
@nivel_de_acesso = nivel_de_acesso
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_h
|
50
|
+
{
|
51
|
+
id_tipo_procedimento: @id_tipo_procedimento,
|
52
|
+
especificacao: @especificacao,
|
53
|
+
assuntos: @assuntos.nil? ? {} : @assuntos,
|
54
|
+
interessados: @interessados.nil? ? {} : @interessados,
|
55
|
+
observacao: @observacao,
|
56
|
+
nivel_de_acesso: @nivel_de_acesso
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
module Estruturas
|
4
|
+
|
5
|
+
class RetornoGeracaoProcedimento < ::Valuable
|
6
|
+
|
7
|
+
has_value :id_procedimento
|
8
|
+
has_value :procedimento_formatado
|
9
|
+
has_value :link_acesso
|
10
|
+
has_collection :retorno_inclusao_documentos, klass: RetornoInclusaoDocumento
|
11
|
+
|
12
|
+
def initialize(params)
|
13
|
+
self.id_procedimento = params[:id_procedimento]
|
14
|
+
self.procedimento_formatado = params[:procedimento_formatado]
|
15
|
+
self.link_acesso = params[:link_acesso]
|
16
|
+
self.retorno_inclusao_documentos = []
|
17
|
+
if params[:retorno_inclusao_documentos] && params[:retorno_inclusao_documentos][:item]
|
18
|
+
item = params[:retorno_inclusao_documentos][:item]
|
19
|
+
if item.is_a?(Hash)
|
20
|
+
self.retorno_inclusao_documentos << Sei::Estruturas::RetornoInclusaoDocumento.new(item)
|
21
|
+
elsif item.is_a?(Array)
|
22
|
+
item.each do |retorno_inclusao_documento|
|
23
|
+
self.retorno_inclusao_documentos << Sei::Estruturas::RetornoInclusaoDocumento.new(retorno_inclusao_documento)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
initialize_attributes
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
module Estruturas
|
4
|
+
|
5
|
+
class RetornoInclusaoDocumento < ::Valuable
|
6
|
+
|
7
|
+
has_value :id_documento
|
8
|
+
has_value :documento_formatado
|
9
|
+
has_value :link_acesso
|
10
|
+
|
11
|
+
def initialize(params)
|
12
|
+
self.id_documento = params[:id_documento]
|
13
|
+
self.documento_formatado = params[:documento_formatado]
|
14
|
+
self.link_acesso = params[:link_acesso]
|
15
|
+
initialize_attributes
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/sei/printer.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "json"
|
2
|
+
require "nokogiri"
|
3
|
+
|
4
|
+
module Sei
|
5
|
+
|
6
|
+
module Printer
|
7
|
+
|
8
|
+
def self.jp(json_text)
|
9
|
+
puts JSON.pretty_generate json_text
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.xp(xml_text)
|
13
|
+
xsl = <<~HEREDOC
|
14
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
15
|
+
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
|
16
|
+
<xsl:strip-space elements="*"
|
17
|
+
<xsl:template match="/">
|
18
|
+
<xsl:copy-of select="."/>
|
19
|
+
</xsl:template>
|
20
|
+
</xsl:stylesheet>
|
21
|
+
HEREDOC
|
22
|
+
|
23
|
+
doc = Nokogiri::XML(xml_text)
|
24
|
+
xslt = Nokogiri::XSLT(xsl)
|
25
|
+
out = xslt.transform(doc)
|
26
|
+
|
27
|
+
puts out.to_xml
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/sei/servico.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Sei
|
2
|
+
|
3
|
+
module Servico
|
4
|
+
|
5
|
+
def self.gerar_procedimento(id_unidade, procedimento, documentos = [], procedimentos_relacionados = [], unidades_envio = [], manter_aberto_unidade = 'N',
|
6
|
+
enviar_email_notificacao = 'N', data_retorno_programado = nil, dias_retorno_programado = nil, dias_uteis_retorno_programado = 'N')
|
7
|
+
message = {
|
8
|
+
SiglaSistema: Sei.configuration.sigla,
|
9
|
+
IdentificacaoServico: Sei.configuration.identificacao,
|
10
|
+
IdUnidade: id_unidade,
|
11
|
+
Procedimento: procedimento.to_h,
|
12
|
+
Documentos: documentos.empty? ? {} : {documento: documentos.map{|documento| documento.to_h}},
|
13
|
+
ProcedimentosRelacionados: procedimentos_relacionados.empty? ? {} : {procedimento_relacionado: procedimentos_relacionados.map{|procedimentos_relacionado| procedimentos_relacionado.to_h}},
|
14
|
+
UnidadesEnvio: unidades_envio.empty? ? {} : {unidade_envio: unidades_envio.map{|unidade_envio| unidade_envio.to_message}},
|
15
|
+
SinManterAbertoUnidade: manter_aberto_unidade,
|
16
|
+
SinEnviarEmailNotificacao: enviar_email_notificacao,
|
17
|
+
DataRetornoProgramado: data_retorno_programado,
|
18
|
+
DiasRetornoProgramado: dias_retorno_programado,
|
19
|
+
SinDiasUteisRetornoProgramado: dias_uteis_retorno_programado
|
20
|
+
}
|
21
|
+
response = Sei::Connection.instance.call :gerar_procedimento, message: message
|
22
|
+
body = response.body[:gerar_procedimento_response][:parametros]
|
23
|
+
Sei::Estruturas::RetornoGeracaoProcedimento.new body
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.incluir_documento(id_unidade, documento)
|
27
|
+
message = {
|
28
|
+
SiglaSistema: Sei.configuration.sigla,
|
29
|
+
IdentificacaoServico: Sei.configuration.identificacao,
|
30
|
+
IdUnidade: id_unidade,
|
31
|
+
Documento: documento.to_h
|
32
|
+
}
|
33
|
+
response = Sei::Connection.instance.call :incluir_documento, message: message
|
34
|
+
body = response.body[:incluir_documento_response][:parametros]
|
35
|
+
Sei::Estruturas::RetornoInclusaoDocumento.new body
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/sei/version.rb
ADDED
data/sei.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sei/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sei"
|
8
|
+
spec.version = Sei::VERSION
|
9
|
+
spec.authors = ["Leandro Telles"]
|
10
|
+
spec.email = ["tellesleandro@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Integração com a API do SEI."
|
13
|
+
spec.description = "Expõe, através de métodos ruby, as funcionalidades da API do SEI."
|
14
|
+
spec.homepage = "https://github.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
spec.add_development_dependency 'gem_config'
|
37
|
+
spec.add_development_dependency 'savon'
|
38
|
+
spec.add_development_dependency 'valuable'
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sei
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leandro Telles
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gem_config
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: savon
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: valuable
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Expõe, através de métodos ruby, as funcionalidades da API do SEI.
|
98
|
+
email:
|
99
|
+
- tellesleandro@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".ruby-gemset"
|
106
|
+
- ".ruby-version"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- lib/sei.rb
|
116
|
+
- lib/sei/connection.rb
|
117
|
+
- lib/sei/estruturas/documento.rb
|
118
|
+
- lib/sei/estruturas/procedimento.rb
|
119
|
+
- lib/sei/estruturas/retorno_geracao_procedimento.rb
|
120
|
+
- lib/sei/estruturas/retorno_inclusao_documento.rb
|
121
|
+
- lib/sei/printer.rb
|
122
|
+
- lib/sei/servico.rb
|
123
|
+
- lib/sei/version.rb
|
124
|
+
- sei.gemspec
|
125
|
+
homepage: https://github.com
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata:
|
129
|
+
allowed_push_host: https://rubygems.org
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.5.1
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Integração com a API do SEI.
|
150
|
+
test_files: []
|