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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b52aa6ff3963bfb2e0a4058af3f9075897e7ad18
4
- data.tar.gz: 66850c91f2df81317d42f84515186324ce8a7e90
2
+ SHA256:
3
+ metadata.gz: 2a54b75dd8f97b5c6fba51679e38a9cc5ec6eec8de9b6837210fbd41a6a331df
4
+ data.tar.gz: d77939985019b8b2982fcd5ec5627b1ceea3c0eeda04aef89a9ed19234f76103
5
5
  SHA512:
6
- metadata.gz: a1fdeda4f1ddb4a02f299bddc650a83d72e1de127a388b830ffe08171b377444ec04da1f81fae12dea1b304013cc95c66ef7bf539f9d7e4a145d37016411e741
7
- data.tar.gz: fd13bf962d41dbe93301cb9d1ac3cb4425fd91ad5da18650216d40180e0fc72ad67375665d91964da735d7a3ca7e68f6683cac0242971fbab67ce614318902bc
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
+ [![Build Status](https://travis-ci.org/fabianoarruda/sinesp_client.svg?branch=master)](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 = "TRwf1iBwvCoSboSscGne"
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 = "<?xml version='1.0' encoding='utf-8'?>
25
- <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
26
- <soap:Header>
27
- <b>motorola XT1078</b>
28
- <c>ANDROID</c>
29
- <i>#{lat}</i>
30
- <m>8797e74f0d6eb7b1ff3dc114d4aa12d3</m>
31
- <e>4.1.1</e>
32
- <f>10.0.0.1</f>
33
- <g>#{hash}</g>
34
- <d>6.0</d>
35
- <h>#{long}</h>
36
- <k />
37
- <l>#{Time.now}</l>
38
- </soap:Header>
39
- <soap:Body>
40
- <webs:getStatus xmlns:webs=\"http://soap.ws.placa.service.sinesp.serpro.gov.br/\">
41
- <a>#{plate}</a>
42
- </webs:getStatus>
43
- </soap:Body>
44
- </soap:Envelope>"
45
-
46
- headers = { "Content-type" => "text/xml; charset=utf-8",
47
- "Timeout" => "30000",
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 / 3.0.2.1 CFNetwork / 758.2.8 Darwin / 15.0.0"
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
- response = post("http://sinespcidadao.sinesp.gov.br/sinesp-cidadao/mobile/consultar-placa", body: body, headers: headers, timeout: 10)
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 response["Envelope"]["Body"]["getStatusResponse"]["return"]["codigoRetorno"] == "0"
64
- response["Envelope"]["Body"]["getStatusResponse"]["return"]
65
- #else
66
- # nil
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
 
@@ -1,3 +1,3 @@
1
1
  module SinespClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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: 2016-11-20 00:00:00.000000000 Z
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.5.1
108
+ rubygems_version: 2.7.3
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Sinesp Client gem.