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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 135028c00132eb8f1ad36e1d9e5e5f0006bb939fac56e408abd27fbd4720f13e
4
- data.tar.gz: 282bb983bac0041b9aef9eec6f0104caa19f695b200a093f57836ccae74d514b
3
+ metadata.gz: 3cca32eb7b4677d4370f0d7a0886822169046933e49d4f4ee9b3d1c2ebb65628
4
+ data.tar.gz: fe620b8bb1abc8fa635ebabc051794bdd1189f09fd8d35d8f05caf7d4633169c
5
5
  SHA512:
6
- metadata.gz: 33f4cc6cff1320f1c1ace92720d60d78ac09bf792dea26edbc81108d2ba395286104076f2cc7f253df3accee0f201abcecfe3cf8aef18fc1d9d8759823966bef
7
- data.tar.gz: 62a48b9d6c1b64764ab95a43f9b29df330720fa905a40458127610713885bab941622d37ad4656cb2c67570541e39fa494228801cb6f6ab25d98a40c0cd39b72
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: 'get')
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] = 'get'
16
- options[:ibge] ||= '2211001'
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
@@ -1,3 +1,3 @@
1
1
  module SticapiClient
2
- VERSION = "3.1.6"
2
+ VERSION = "3.1.8"
3
3
  end
@@ -1,22 +1,21 @@
1
- # encoding: utf-8
2
- require 'sticapi_client/version'
3
- require 'singleton'
4
- require 'devise'
5
- require 'rails'
6
- require 'sticapi_client/sticapi_devise_strategy'
7
- require 'sticapi_client/sticapi_controller'
8
- require 'sticapi_client/diario'
9
- require 'sticapi_client/etjpi'
10
- require 'sticapi_client/intranet'
11
- require 'sticapi_client/gestorh'
12
- require 'sticapi_client/pessoas'
13
- require 'sticapi_client/sip'
14
- require 'sticapi_client/themis'
15
- require 'sticapi_client/transparencia'
16
- require 'sticapi_client/user'
17
- require 'sticapi_client/group'
18
- require 'sticapi_client/ou'
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
- # configs = YAML.load_file("/home/ricardo/dev/sticapi_client/lib/generators/sticapi_client/templates/sticapi.yml")[Rails.env]
39
- @host = configs['host']
40
- @port = configs['port'] || 80
41
- @user = configs['user']
42
- @urn = configs['urn']
43
- @ssl = configs['ssl'] || false
44
- @password = configs['password']
45
- @access_token = ''
46
- @client = ''
47
- @uid = ''
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#{'s' if @ssl}://#{@host}:#{@port}#{'/' if @urn}#{@urn}"
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['Content-Type'] = 'application/json'
63
- request['email'] = @user
64
- request['password'] = @password
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['access-token'] if response['access-token']
72
- @client = response['client'] if response['client']
73
- @uid = response['uid'] if response['uid']
74
- @expiry = response['expiry'] if response['expiry']
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] || 'post'
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 == 'post'
85
- request = Net::HTTP::Get.new(uri.request_uri) if kind == 'get'
86
- request['Content-Type'] = 'application/json'
87
- request['access-token'] = access_token
88
- request['client'] = client
89
- request['uid'] = uid
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
- :route => :session, ## This will add the routes, rather than in the routes.rb
102
- :strategy => true,
103
- :controller => :sessions)
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.6
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-28 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails