sticapi_client 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: a66e7d0b3880e36c1d6662a3c1bd2d79ee33440a
4
- data.tar.gz: 17c220cb2f677702b183f3fc288755358f6650c1
3
+ metadata.gz: e77c85ae5837ea3d5f7969161e0032a560688cfb
4
+ data.tar.gz: 66781ba65d0ca54c915744983e28ab83bc925389
5
5
  SHA512:
6
- metadata.gz: cf8cace096d58a6d168aae4fa9fe600f82348f54e84ceb7f965ef1bffeb4dc5a44613585724e94791b451243e179bdff07e804e2d73db356fdb28234d5df5867
7
- data.tar.gz: a976e5ef6c905b716c01958543dbe92f4447bc17ebbd554e8c963e3d1642092ae0250c19ba4bab26a5d48073326817137509d212e599a73c40333149053729e7
6
+ metadata.gz: 869a1dff86410e98c2f9854c7a239e27fa47ffe6653a8a0c973d69213dab0eb008af2d19d9b9b6a1ba69b8039cf5d1d8d6da9023b26c44b65fba5da283b0aac6
7
+ data.tar.gz: 2dcf61916d56f540c27535a5d255d6697f354da5c1cecff45bfcf23723a366a06345a73e56328dd0195eb35fb1480d9d53697561244e0f02e669f3fb8c1e3bfb
@@ -0,0 +1,7 @@
1
+ module Etjpi
2
+ class Etjpi
3
+ def self.id_to_processo(id)
4
+ SticapiClient::SticapiClient.instance.sticapi_request('/etjpi/id_to_processo', id: id)
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SticapiClient
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -5,6 +5,7 @@ require 'devise'
5
5
  require 'rails'
6
6
  require 'sticapi_client/sticapi_devise_strategy'
7
7
  require 'sticapi_client/sticapi_controller'
8
+ require 'sticapi_client/etjpi'
8
9
  require 'net/http'
9
10
 
10
11
  module SticapiClient
@@ -22,8 +23,8 @@ module SticapiClient
22
23
  attr_accessor :expiry
23
24
 
24
25
  def initialize
25
- configs = YAML.load_file("#{Rails.root}/config/sticapi.yml")[Rails.env]
26
- # configs = YAML.load_file("/home/ricardo/dev/sticapi_client/lib/generators/sticapi_client/templates/sticapi.yml")[Rails.env]
26
+ # configs = YAML.load_file("#{Rails.root}/config/sticapi.yml")[Rails.env]
27
+ configs = YAML.load_file("/home/ricardo/dev/sticapi_client/lib/generators/sticapi_client/templates/sticapi.yml")[Rails.env]
27
28
  @host = configs['host']
28
29
  @port = configs['port'] || 80
29
30
  @user = configs['user']
@@ -33,6 +34,7 @@ module SticapiClient
33
34
  @client = ''
34
35
  @uid = ''
35
36
  @expiry = ''
37
+ get_token
36
38
  end
37
39
 
38
40
  def uri
@@ -57,6 +59,23 @@ module SticapiClient
57
59
  @uid = response['uid']
58
60
  @expiry = response['expiry']
59
61
  end
62
+
63
+ def sticapi_request(route, options = {})
64
+ kind = options[:kind] || 'post'
65
+ uri = URI.parse("#{self.uri}#{route}")
66
+ http = Net::HTTP.new(uri.host, uri.port)
67
+ request = nil
68
+ request = Net::HTTP::Post.new(uri.request_uri) if kind == 'post'
69
+ request = Net::HTTP::Get.new(uri.request_uri) if kind == 'get'
70
+ request['Content-Type'] = 'application/json'
71
+ request['access-token'] = access_token
72
+ request['client'] = client
73
+ request['uid'] = uid
74
+ request.body = options.except(:kind).to_json
75
+ response = http.request(request)
76
+ update_token(response)
77
+ JSON.parse(response.body)
78
+ end
60
79
  end
61
80
  end
62
81
 
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: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Viana
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ files:
104
104
  - lib/generators/sticapi_client/install_generator.rb
105
105
  - lib/generators/sticapi_client/templates/sticapi.yml
106
106
  - lib/sticapi_client.rb
107
+ - lib/sticapi_client/etjpi.rb
107
108
  - lib/sticapi_client/sticapi_controller.rb
108
109
  - lib/sticapi_client/sticapi_devise_strategy.rb
109
110
  - lib/sticapi_client/version.rb