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,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,17 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoBoolean < ::Valuable
6
+
7
+ has_value :status
8
+
9
+ def initialize(params)
10
+ self.status = params
11
+ initialize_attributes
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoConclusaoProcesso < ::Valuable
6
+
7
+ has_value :status
8
+
9
+ def initialize(params)
10
+ self.status = params
11
+ initialize_attributes
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,29 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoConsultarProcedimento < ::Valuable
6
+
7
+ has_value :idProcedimento
8
+ has_value :procedimentoFormatado
9
+ has_value :especificacao
10
+ has_value :dataAutuacao
11
+ has_value :linkAcesso
12
+ has_value :tipoProcedimento
13
+
14
+
15
+ def initialize(params)
16
+ self.idProcedimento = params[:idProcedimento]
17
+ self.procedimentoFormatado = params[:procedimentoFormatado]
18
+ self.especificacao = params[:especificacao]
19
+ self.dataAutuacao = params[:dataAutuacao]
20
+ self.linkAcesso = params[:linkAcesso]
21
+ self.tipoProcedimento = params[:tipoProcedimento]
22
+ initialize_attributes
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,18 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoGeracaoBloco < ::Valuable
6
+
7
+ has_value :bloco_gerado
8
+
9
+ def initialize(params)
10
+ self.bloco_gerado = params
11
+ initialize_attributes
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+
18
+ 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
@@ -0,0 +1,17 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoInclusaoDocumentoBloco < ::Valuable
6
+
7
+ has_value :status
8
+
9
+ def initialize(params)
10
+ self.status = params
11
+ initialize_attributes
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoInclusaoProcessoBloco < ::Valuable
6
+
7
+ has_value :status
8
+
9
+ def initialize(params)
10
+ self.status = params
11
+ initialize_attributes
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,31 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoListUnidades < ::Valuable
6
+
7
+ has_collection :retorno_list_unidades, klass: RetornoUnidade
8
+
9
+ def initialize(params)
10
+
11
+ self.retorno_list_unidades = []
12
+ item = params[:item]
13
+ if item.is_a?(Hash)
14
+ self.retorno_list_unidades << Sei::Estruturas::RetornoUnidade.new(item)
15
+ elsif item.is_a?(Array)
16
+ item.each do |retorno_lista_unidades|
17
+ self.retorno_list_unidades << Sei::Estruturas::RetornoUnidade.new(retorno_lista_unidades)
18
+ end
19
+
20
+ end
21
+
22
+ initialize_attributes
23
+ end
24
+ def teste(params)
25
+ debugger
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,26 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoListUsuarios < ::Valuable
6
+
7
+ has_collection :retorno_list_usuarios, klass: RetornoUsuario
8
+
9
+ def initialize(params)
10
+ self.retorno_list_usuarios = []
11
+ item = params[:item]
12
+ if item.is_a?(Hash)
13
+ self.retorno_list_usuarios << Sei::Estruturas::RetornoUsuario.new(item)
14
+ elsif item.is_a?(Array)
15
+ item.each do |retorno_lista_unidades|
16
+ self.retorno_list_usuarios << Sei::Estruturas::RetornoUsuario.new(retorno_lista_unidades)
17
+ end
18
+ end
19
+ initialize_attributes
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,22 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoUnidade < ::Valuable
6
+
7
+ has_value :id_unidade
8
+ has_value :sigla
9
+ has_value :descricao
10
+
11
+ def initialize(params)
12
+ self.id_unidade = params[:id_unidade]
13
+ self.sigla = params[:sigla]
14
+ self.descricao = params[:descricao]
15
+
16
+ initialize_attributes
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ module Sei
2
+
3
+ module Estruturas
4
+
5
+ class RetornoUsuario < ::Valuable
6
+
7
+ has_value :idUsuario
8
+ has_value :sigla
9
+ has_value :nome
10
+
11
+ def initialize(params)
12
+ self.idUsuario = params[:id_usuario]
13
+ self.sigla = params[:sigla]
14
+ self.nome = params[:nome]
15
+ initialize_attributes
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -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
@@ -0,0 +1,243 @@
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
+
9
+ SiglaSistema: Sei.configuration.sigla,
10
+ IdentificacaoServico: Sei.configuration.identificacao,
11
+ IdUnidade: id_unidade,
12
+ Procedimento: procedimento.to_h,
13
+ Documentos: documentos.empty? ? {} : {documento: documentos.map{|documento| documento.to_h}},
14
+ ProcedimentosRelacionados: procedimentos_relacionados.empty? ? {} : {procedimento_relacionado: procedimentos_relacionados.map{|procedimentos_relacionado| procedimentos_relacionado.to_h}},
15
+ UnidadesEnvio: unidades_envio.empty? ? {} : {unidade_envio: unidades_envio.map{|unidade_envio| unidade_envio.to_message}},
16
+ SinManterAbertoUnidade: manter_aberto_unidade,
17
+ SinEnviarEmailNotificacao: enviar_email_notificacao,
18
+ DataRetornoProgramado: data_retorno_programado,
19
+ DiasRetornoProgramado: dias_retorno_programado,
20
+ SinDiasUteisRetornoProgramado: dias_uteis_retorno_programado
21
+ }
22
+ response = Sei::Connection.instance.call :gerar_procedimento, message: message
23
+
24
+ body = response.body[:gerar_procedimento_response][:parametros]
25
+ Sei::Estruturas::RetornoGeracaoProcedimento.new body
26
+ end
27
+
28
+ def self.incluir_documento(id_unidade, documento)
29
+ message = {
30
+ SiglaSistema: Sei.configuration.sigla,
31
+ IdentificacaoServico: Sei.configuration.identificacao,
32
+ IdUnidade: id_unidade,
33
+ Documento: documento.to_h
34
+ }
35
+ response = Sei::Connection.instance.call :incluir_documento, message: message
36
+ body = response.body[:incluir_documento_response][:parametros]
37
+ Sei::Estruturas::RetornoInclusaoDocumento.new body
38
+ end
39
+
40
+ def self.incluir_documento_bloco(id_unidade,id_bloco,protocolo_documento)
41
+ message = {
42
+ SiglaSistema: Sei.configuration.sigla,
43
+ IdentificacaoServico: Sei.configuration.identificacao,
44
+ IdUnidade: id_unidade,
45
+ IdBloco: id_bloco,
46
+ ProtocoloDocumento: protocolo_documento
47
+ }
48
+
49
+ response = Sei::Connection.instance.call :incluir_documento_bloco, message: message
50
+ body = response.body[:incluir_documento_bloco_response][:parametros]
51
+ Sei::Estruturas::RetornoInclusaoDocumentoBloco.new body
52
+ end
53
+
54
+ def self.incluir_processo_bloco(id_unidade,id_bloco,protocolo_procedimento)
55
+ message = {
56
+ SiglaSistema: Sei.configuration.sigla,
57
+ IdentificacaoServico: Sei.configuration.identificacao,
58
+ IdUnidade: id_unidade,
59
+ IdBloco: id_bloco,
60
+ ProtocoloProcedimento: protocolo_procedimento
61
+ }
62
+
63
+ response = Sei::Connection.instance.call :incluir_processo_bloco, message: message
64
+ body = response.body[:incluir_processo_bloco_response][:parametros]
65
+ Sei::Estruturas::RetornoInclusaoProcessoBloco.new body
66
+ end
67
+
68
+ #metodos não testados ainda
69
+ def self.concluir_processo(id_unidade,protocolo_procedimento)
70
+ message = {
71
+ SiglaSistema: Sei.configuration.sigla,
72
+ IdentificacaoServico: Sei.configuration.identificacao,
73
+ IdUnidade: id_unidade,
74
+ ProtocoloProcedimento: protocolo_procedimento
75
+ }
76
+
77
+ response = Sei::Connection.instance.call :concluir_processo, message: message
78
+ body = response.body[:concluir_processo_response][:parametros]
79
+ Sei::Estruturas::RetornoConclusaoProcesso.new body
80
+
81
+ end
82
+
83
+ def self.reabrir_processo(id_unidade,protocolo_procedimento)
84
+ message = {
85
+ SiglaSistema: Sei.configuration.sigla,
86
+ IdentificacaoServico: Sei.configuration.identificacao,
87
+ IdUnidade: id_unidade,
88
+ ProtocoloProcedimento: protocolo_procedimento
89
+ }
90
+
91
+ response = Sei::Connection.instance.call :reabrir_processo, message: message
92
+ body = response.body[:reabrir_processo_response][:parametros]
93
+ Sei::Estruturas::RetornoBoolean.new body
94
+
95
+ end
96
+
97
+ def self.retirar_processo_bloco(id_unidade,id_bloco,protocolo_procedimento)
98
+ message = {
99
+ SiglaSistema: Sei.configuration.sigla,
100
+ IdentificacaoServico: Sei.configuration.identificacao,
101
+ IdUnidade: id_unidade,
102
+ IdBloco: id_bloco,
103
+ ProtocoloProcedimento: protocolo_procedimento
104
+ }
105
+
106
+ response = Sei::Connection.instance.call :retirar_processo_bloco, message: message
107
+ body = response.body[:retirar_processo_bloco_response][:parametros]
108
+ Sei::Estruturas::RetornoBoolean.new body
109
+ end
110
+
111
+ def self.atribuir_processo(id_unidade,protocolo_procedimento,id_usuario,sinReabrir = 'N')
112
+
113
+ message = {
114
+ SiglaSistema: Sei.configuration.sigla,
115
+ IdentificacaoServico: Sei.configuration.identificacao,
116
+ IdUnidade: id_unidade,
117
+ ProtocoloProcedimento: protocolo_procedimento,
118
+ IdUsuario: id_usuario,
119
+ SinReabrir: sinReabrir
120
+
121
+ }
122
+
123
+ response = Sei::Connection.instance.call :atribuir_processo, message: message
124
+ body = response.body[:atribuir_processo_response][:parametros]
125
+ Sei::Estruturas::RetornoBoolean.new body
126
+ end
127
+
128
+ def self.retirar_documento_bloco(id_unidade,id_bloco,protocolo_documento)
129
+ message = {
130
+ SiglaSistema: Sei.configuration.sigla,
131
+ IdentificacaoServico: Sei.configuration.identificacao,
132
+ IdUnidade: id_unidade,
133
+ IdBloco: id_bloco,
134
+ ProtocoloDocumento: protocolo_documento
135
+ }
136
+
137
+ response = Sei::Connection.instance.call :retirar_documento_bloco, message: message
138
+ body = response.body[:retirar_documento_bloco_response][:parametros]
139
+ Sei::Estruturas::RetornoBoolean.new body
140
+ end
141
+
142
+ def self.disponibilizar_bloco(id_unidade,id_bloco)
143
+ message = {
144
+ SiglaSistema: Sei.configuration.sigla,
145
+ IdentificacaoServico: Sei.configuration.identificacao,
146
+ IdUnidade: id_unidade,
147
+ IdBloco: id_bloco
148
+ }
149
+
150
+ response = Sei::Connection.instance.call :disponibilizar_bloco, message: message
151
+ body = response.body[:disponibilizar_bloco_response][:parametros]
152
+ Sei::Estruturas::RetornoBoolean.new body
153
+ end
154
+
155
+ def self.excluir_bloco(id_unidade,id_bloco)
156
+ message = {
157
+ SiglaSistema: Sei.configuration.sigla,
158
+ IdentificacaoServico: Sei.configuration.identificacao,
159
+ IdUnidade: id_unidade,
160
+ IdBloco: id_bloco
161
+ }
162
+
163
+ response = Sei::Connection.instance.call :excluir_bloco, message: message
164
+ body = response.body[:excluir_bloco_response][:parametros]
165
+ Sei::Estruturas::RetornoBoolean.new body
166
+ end
167
+
168
+ def self.cancelar_documento(id_unidade,protocoloDocumento,motivo)
169
+ message = {
170
+ SiglaSistema: Sei.configuration.sigla,
171
+ IdentificacaoServico: Sei.configuration.identificacao,
172
+ IdUnidade: id_unidade,
173
+ ProtocoloDocumento: protocoloDocumento,
174
+ Motivo: motivo
175
+ }
176
+
177
+ response = Sei::Connection.instance.call :cancelar_documento, message: message
178
+ body = response.body[:cancelar_documento_response][:parametros]
179
+ Sei::Estruturas::RetornoBoolean.new body
180
+ end
181
+
182
+
183
+ def self.listar_usuarios(idUnidade,idUsuario = nil)
184
+ message = {
185
+ SiglaSistema: Sei.configuration.sigla,
186
+ IdentificacaoServico: Sei.configuration.identificacao,
187
+
188
+ IdUnidade: idUnidade,
189
+ IdUsuario: idUsuario
190
+ }
191
+ response = Sei::Connection.instance.call :listar_usuarios, message: message
192
+ body = response.body[:listar_usuarios_response][:parametros]
193
+ Sei::Estruturas::RetornoListUsuarios.new body
194
+ end
195
+
196
+ def self.consultar_procedimento(idUnidade,protocoloProcedimento,sinRetornarAssuntos = 'N',sinRetornarInteressados = 'N',sinRetornarObservacoes = 'N',sinRetornarAndamentoGeracao = 'N',sinRetornarAndamentoConclusao = 'N')
197
+ message = {
198
+ SiglaSistema: Sei.configuration.sigla,
199
+ IdentificacaoServico: Sei.configuration.identificacao,
200
+ IdUnidade: idUnidade,
201
+ ProtocoloProcedimento: protocoloProcedimento
202
+
203
+ }
204
+ response = Sei::Connection.instance.call :consultar_procedimento, message: message
205
+ body = response.body[:consultar_procedimento_response][:parametros]
206
+ Sei::Estruturas::RetornoConsultarProcedimento.new body
207
+ end
208
+
209
+
210
+ #até aqui
211
+
212
+
213
+
214
+ def self.listar_unidades(idTipoProcedimento = nil,idSerie = nil)
215
+ message = {
216
+ SiglaSistema: Sei.configuration.sigla,
217
+ IdentificacaoServico: Sei.configuration.identificacao,
218
+ IdTipoProcedimento: idTipoProcedimento,
219
+ IdSerie: idSerie
220
+ }
221
+ response = Sei::Connection.instance.call :listar_unidades, message: message
222
+ body = response.body[:listar_unidades_response][:parametros]
223
+ Sei::Estruturas::RetornoListUnidades.new body
224
+ end
225
+
226
+ def self.gerar_bloco(id_unidade, tipo, descricao,unidadesDisponibilizacao = [], documentos = [], sinDisponibilizar = 'N')
227
+ message = {
228
+ SiglaSistema: Sei.configuration.sigla,
229
+ IdentificacaoServico: Sei.configuration.identificacao,
230
+ IdUnidade: id_unidade,
231
+ Tipo: tipo,
232
+ Descricao: descricao,
233
+ UnidadesDisponibilizacao: unidadesDisponibilizacao,
234
+ SinDisponibilizar: sinDisponibilizar
235
+ }
236
+ response = Sei::Connection.instance.call :gerar_bloco, message: message
237
+
238
+ body = response.body[:gerar_bloco_response][:parametros]
239
+ Sei::Estruturas::RetornoGeracaoBloco.new body
240
+ end
241
+ end
242
+
243
+ end