sinesp_client 0.1.2 → 0.1.3
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 +5 -5
- data/README.md +2 -0
- data/lib/sinesp_client.rb +37 -34
- data/lib/sinesp_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a54b75dd8f97b5c6fba51679e38a9cc5ec6eec8de9b6837210fbd41a6a331df
|
4
|
+
data.tar.gz: d77939985019b8b2982fcd5ec5627b1ceea3c0eeda04aef89a9ed19234f76103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6da8160872208ad0e522ee5a9377b6dc132f5dbb88a751c8cf2d163c0c390294b053ec06cddba4408edbdc1b70758d0f4db653b29669358d256b77bd8313f54
|
7
|
+
data.tar.gz: '07174490fb4088780210916d3f7ef262a464ee14b5c1c435e632d65e27b54bef57bab2a957886ae302ff74a33d50dc7c8afe9d42446c16bc5e61ad1c02aa11bd'
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
# Ruby Sinesp Client
|
3
3
|
|
4
|
+
[](https://travis-ci.org/fabianoarruda/sinesp_client)
|
5
|
+
|
4
6
|
This gem provides a client for searching vehicle data based on the license plate from Sinesp database. This data is publicly available at https://www.sinesp.gov.br/sinesp-cidadao. The gem just makes it easier to fetch results, through the same endpoint used by the mobile app.
|
5
7
|
|
6
8
|
For a python version, please check this: https://github.com/victor-torres/sinesp-client
|
data/lib/sinesp_client.rb
CHANGED
@@ -3,10 +3,13 @@ require 'openssl'
|
|
3
3
|
require 'httparty'
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
|
+
|
6
7
|
module SinespClient
|
7
8
|
|
8
9
|
include HTTParty
|
9
10
|
|
11
|
+
default_options.update(verify: false)
|
12
|
+
|
10
13
|
def self.lat
|
11
14
|
rand(-90.000000000...90.000000000)
|
12
15
|
end
|
@@ -17,54 +20,54 @@ module SinespClient
|
|
17
20
|
|
18
21
|
def self.search(plate)
|
19
22
|
|
20
|
-
key = "
|
23
|
+
key = "#8.1.0#Mw6HqdLgQsX41xAGZgsF"
|
21
24
|
digest = OpenSSL::Digest.new('sha1')
|
22
25
|
hash = OpenSSL::HMAC.hexdigest(digest, plate + key, plate)
|
23
26
|
|
24
|
-
body = "
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
headers = { "Content-type" => "
|
47
|
-
"
|
27
|
+
body = "<v:Envelope xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\" xmlns:c=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:v=\"http://schemas.xmlsoap.org/soap/envelope/\">
|
28
|
+
<v:Header>
|
29
|
+
<b>Google Android SDK built for x86</b>
|
30
|
+
<c>ANDROID</c>
|
31
|
+
<d>8.1.0</d>
|
32
|
+
<e>4.3.2</e>
|
33
|
+
<f>10.0.2.15</f>
|
34
|
+
<g>#{hash}</g>
|
35
|
+
<h>#{long}</h>
|
36
|
+
<i>#{lat}</i>
|
37
|
+
<k />
|
38
|
+
<l>#{Time.now}</l>
|
39
|
+
<m>8797e74f0d6eb7b1ff3dc114d4aa12d3</m>
|
40
|
+
</v:Header>
|
41
|
+
<v:Body>
|
42
|
+
<n0:getStatus xmlns:n0=\"http://soap.ws.placa.service.sinesp.serpro.gov.br/\">
|
43
|
+
<a>#{plate}</a>
|
44
|
+
</n0:getStatus>
|
45
|
+
</v:Body>
|
46
|
+
</v:Envelope>"
|
47
|
+
|
48
|
+
|
49
|
+
headers = { "Content-type" => "application/x-www-form-urlencoded; charset=UTF-8",
|
50
|
+
"Accept" => "text/plain, */*; q=0.01",
|
51
|
+
"Cache-Control" => "no-cache",
|
52
|
+
"Pragma" => "no-cache",
|
48
53
|
"Content-length" => body.length.to_s,
|
49
|
-
"User-Agent" => "SinespCidadao
|
54
|
+
"User-Agent" => "SinespCidadao/4.2.3 CFNetwork/808.1.4 Darwin/16.1.0"
|
50
55
|
}
|
51
56
|
|
52
|
-
|
53
57
|
#begin
|
54
58
|
|
55
|
-
|
59
|
+
response = post("https://189.9.194.154/sinesp-cidadao/mobile/consultar-placa/v3", body: body, headers: headers, timeout: 20)
|
56
60
|
|
57
61
|
#rescue
|
58
62
|
# return nil
|
59
63
|
#end
|
60
64
|
|
61
|
-
|
62
65
|
#If the query is valid, "codigoRetorno" will be 0. Otherwise something went wrong. Just return nil.
|
63
|
-
#if
|
64
|
-
|
65
|
-
#else
|
66
|
-
#
|
67
|
-
#end
|
66
|
+
# if parsed_response[:codigoRetorno] == "0"
|
67
|
+
response["Envelope"]["Body"]["getStatusResponse"]["return"]
|
68
|
+
# else
|
69
|
+
# nil
|
70
|
+
# end
|
68
71
|
|
69
72
|
end
|
70
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinesp_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabiano Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.7.3
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Sinesp Client gem.
|