sei-ima 0.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cdd130b2ad8a5271dfcfbc3b58e9d459da15b48d
4
+ data.tar.gz: 271b8381b6a85ab7c97bbe94163e6c75d6a58ca2
5
+ SHA512:
6
+ metadata.gz: 4e7c07cae917196e578d7ca0b2c4ed30203dac0dfddfb2e0e5b340c8432ee1ab3a5ffb4fd8bf2e62f46bae4aebf9f03c96154b6f6c3c4a91a847d1390e9bb43f
7
+ data.tar.gz: 8ece6eeb36d5568fe8876f397346df3638349599d84fbca72381ea0d1c8378d6f77a9657cee9f23497062d83617ad811c4aa50f8f0044278acc68dfcb4c341a3
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1 @@
1
+ sei
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.13.6
@@ -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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sei.gemspec
4
+ gemspec
@@ -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.
@@ -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
+
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
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
+ require 'sei/estruturas/retorno_unidade'
17
+ require 'sei/estruturas/retorno_list_unidades'
18
+ require 'sei/estruturas/retorno_geracao_bloco'
19
+ require 'sei/estruturas/retorno_inclusao_documento_bloco'
20
+ require 'sei/estruturas/retorno_inclusao_processo_bloco'
21
+ require 'sei/estruturas/retorno_conclusao_processo'
22
+ require 'sei/estruturas/retorno_boolean'
23
+ require 'sei/estruturas/retorno_usuario'
24
+ require 'sei/estruturas/retorno_list_usuarios'
25
+ require 'sei/estruturas/retorno_consultar_procedimento'
26
+
27
+
28
+
29
+ module Sei
30
+
31
+ include GemConfig::Base
32
+
33
+ with_configuration do
34
+ has :wsdl, classes: String
35
+ has :follow_redirects
36
+ has :pretty_print_xml
37
+ has :sigla, classes: String
38
+ has :identificacao, classes: String
39
+ end
40
+
41
+ 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,46 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class DocumentoBloco
6
+
7
+ def id_unidade(id_unidade)
8
+ @tipo = id_unidade
9
+ self
10
+ end
11
+
12
+ def id_bloco(id_bloco)
13
+ @id_bloco = id_bloco
14
+ self
15
+ end
16
+
17
+ def protocolo_documento(protocolo_documento)
18
+ @protocolo_documento = protocolo_documento
19
+ self
20
+ end
21
+
22
+
23
+ def to_h
24
+ {
25
+ tipo: @tipo,
26
+ id_procedimento: @id_procedimento,
27
+ id_serie: @id_serie,
28
+ numero: @numero,
29
+ data: @data,
30
+ descricao: @descricao,
31
+ remetente: @remetente,
32
+ interessados: @interessados.nil? ? {} : @interessados,
33
+ destinatarios: @destinatarios.nil? ? {} : @destinatarios,
34
+ observacao: @observacao,
35
+ nome_arquivo: @nome_arquivo,
36
+ conteudo: @conteudo,
37
+ conteudo_mtom: @conteudo_mtom,
38
+ nivel_de_acesso: @nivel_de_acesso
39
+ }
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end