sticapi_client 3.1.6 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sticapi_client/transparencia.rb +12 -4
- data/lib/sticapi_client/version.rb +1 -1
- data/lib/sticapi_client.rb +47 -48
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cca32eb7b4677d4370f0d7a0886822169046933e49d4f4ee9b3d1c2ebb65628
|
4
|
+
data.tar.gz: fe620b8bb1abc8fa635ebabc051794bdd1189f09fd8d35d8f05caf7d4633169c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7b6a6995ba6dc57107a15592b33ed6ea9356c7a521ced7f6e5797a389868bf301ed55eeeed7e1c9d7468436091cc20c659f40eb713f99b07d89ea452e0288e
|
7
|
+
data.tar.gz: aa339f26af988c0db222d543abec0cec6c9d72ae53fb461ffb65c2fa81a3c65074a1ef2ee7f1712c570ce60f3b5440d42071e2bfdc00c37a4c3d2f7f48cb3ca7
|
@@ -4,17 +4,25 @@ module SticapiClient
|
|
4
4
|
# Retorno [JSON] Quantidade de oficiais de justiça em cada unidade
|
5
5
|
# campos: [id total_oficiais caminho descricao cidade cidade_id cidade_ibge]
|
6
6
|
def self.oficiais_por_unidade
|
7
|
-
Sticapi::SticapiClient.instance.sticapi_request("/transparencia/oficiais_por_unidade", kind:
|
7
|
+
Sticapi::SticapiClient.instance.sticapi_request("/transparencia/oficiais_por_unidade", kind: "get")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# Buscar a lista de processos sobrestados no eTJPI
|
11
11
|
# Parâmetro ibge [String] Código IBGE da cidade (padrão 2211001, Teresina)
|
12
12
|
# Retorno [JSON] Relatório do Município
|
13
13
|
# campos: [dados_intranet dados_themis]
|
14
14
|
def self.municipio_info(options = {})
|
15
|
-
options[:kind] =
|
16
|
-
options[:ibge] ||=
|
15
|
+
options[:kind] = "get"
|
16
|
+
options[:ibge] ||= "2211001"
|
17
17
|
Sticapi::SticapiClient.instance.sticapi_request("/transparencia/municipio_info", options)
|
18
18
|
end
|
19
|
+
|
20
|
+
# Buscar informações da unidade na base do transparência
|
21
|
+
# Parâmetro id [Integer] ID da unidade
|
22
|
+
# Retorno [JSON] Dados da unidade
|
23
|
+
def self.unidade(options = {})
|
24
|
+
options[:kind] = "get"
|
25
|
+
Sticapi::SticapiClient.instance.sticapi_request("/transparencia/unidade", options)
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
data/lib/sticapi_client.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require 'net/http'
|
1
|
+
require "sticapi_client/version"
|
2
|
+
require "singleton"
|
3
|
+
require "devise"
|
4
|
+
require "rails"
|
5
|
+
require "sticapi_client/sticapi_devise_strategy"
|
6
|
+
require "sticapi_client/sticapi_controller"
|
7
|
+
require "sticapi_client/diario"
|
8
|
+
require "sticapi_client/etjpi"
|
9
|
+
require "sticapi_client/intranet"
|
10
|
+
require "sticapi_client/gestorh"
|
11
|
+
require "sticapi_client/pessoas"
|
12
|
+
require "sticapi_client/sip"
|
13
|
+
require "sticapi_client/themis"
|
14
|
+
require "sticapi_client/transparencia"
|
15
|
+
require "sticapi_client/user"
|
16
|
+
require "sticapi_client/group"
|
17
|
+
require "sticapi_client/ou"
|
18
|
+
require "net/http"
|
20
19
|
|
21
20
|
module Sticapi
|
22
21
|
class SticapiClient
|
@@ -35,22 +34,21 @@ module Sticapi
|
|
35
34
|
|
36
35
|
def initialize
|
37
36
|
configs = YAML.load_file("#{Rails.root}/config/sticapi.yml")[Rails.env]
|
38
|
-
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@expiry = ''
|
37
|
+
@host = configs["host"]
|
38
|
+
@port = configs["port"] || 80
|
39
|
+
@user = configs["user"]
|
40
|
+
@urn = configs["urn"]
|
41
|
+
@ssl = configs["ssl"] || false
|
42
|
+
@password = configs["password"]
|
43
|
+
@access_token = ""
|
44
|
+
@client = ""
|
45
|
+
@uid = ""
|
46
|
+
@expiry = ""
|
49
47
|
get_token
|
50
48
|
end
|
51
49
|
|
52
50
|
def uri
|
53
|
-
"http#{
|
51
|
+
"http#{"s" if @ssl}://#{@host}:#{@port}#{"/" if @urn}#{@urn}"
|
54
52
|
end
|
55
53
|
|
56
54
|
def get_token
|
@@ -59,34 +57,35 @@ module Sticapi
|
|
59
57
|
http = Net::HTTP.new(uri.host, uri.port)
|
60
58
|
http.use_ssl = @ssl
|
61
59
|
request = Net::HTTP::Post.new(uri.request_uri)
|
62
|
-
request[
|
63
|
-
request[
|
64
|
-
request[
|
60
|
+
request["Content-Type"] = "application/json"
|
61
|
+
request["email"] = @user
|
62
|
+
request["password"] = @password
|
65
63
|
response = http.request(request)
|
66
64
|
update_token(response)
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
68
|
def update_token(response)
|
71
|
-
@access_token = response[
|
72
|
-
@client = response[
|
73
|
-
@uid = response[
|
74
|
-
@expiry = response[
|
69
|
+
@access_token = response["access-token"] if response["access-token"]
|
70
|
+
@client = response["client"] if response["client"]
|
71
|
+
@uid = response["uid"] if response["uid"]
|
72
|
+
@expiry = response["expiry"] if response["expiry"]
|
75
73
|
end
|
76
74
|
|
77
75
|
def sticapi_request(route, options = {})
|
78
76
|
get_token
|
79
|
-
kind = options[:kind] ||
|
77
|
+
kind = options[:kind] || "post"
|
80
78
|
uri = URI.parse("#{self.uri}#{route}")
|
81
79
|
http = Net::HTTP.new(uri.host, uri.port)
|
82
80
|
http.use_ssl = @ssl
|
83
81
|
request = nil
|
84
|
-
request = Net::HTTP::Post.new(uri.request_uri) if kind ==
|
85
|
-
request = Net::HTTP::Get.new(uri.request_uri) if kind ==
|
86
|
-
request[
|
87
|
-
request[
|
88
|
-
request[
|
89
|
-
request[
|
82
|
+
request = Net::HTTP::Post.new(uri.request_uri) if kind == "post"
|
83
|
+
request = Net::HTTP::Get.new(uri.request_uri) if kind == "get"
|
84
|
+
request["Content-Type"] = "application/json"
|
85
|
+
request["access-token"] = @access_token
|
86
|
+
request["client"] = @client
|
87
|
+
request["uid"] = @uid
|
88
|
+
request["expiry"] = @expiry
|
90
89
|
request.body = options.except(:kind).to_json
|
91
90
|
response = http.request(request)
|
92
91
|
update_token(response)
|
@@ -98,6 +97,6 @@ end
|
|
98
97
|
# Add sticapi_authenticatable strategy to defaults.
|
99
98
|
#
|
100
99
|
Devise.add_module(:sticapi_authenticatable,
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
route: :session, ## This will add the routes, rather than in the routes.rb
|
101
|
+
strategy: true,
|
102
|
+
controller: :sessions)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sticapi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Viana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|