module SinespClientV2
Constants
- ANDROID_VERSION
- BASE_URL
- KEYBASE
- SECRET_KEY
- VERSION
Public Class Methods
search(plate, proxy = {})
click to toggle source
# File lib/sinesp_client_v2.rb, line 14 def self.search(plate, proxy = {}) unless proxy.empty? configure_proxy(proxy[:host], proxy[:port], proxy[:user], proxy[:password]) end @plate = plate.gsub(/\W+/, '') response = post( "https://#{BASE_URL}/sinesp-cidadao/mobile/consultar-placa/v3", body: body, headers: header, timeout: 10, cookies: captcha_cookie, verify: false ) response["Envelope"]["Body"]["getStatusResponse"]["return"].to_h end
Private Class Methods
body()
click to toggle source
# File lib/sinesp_client_v2.rb, line 76 def self.body "<?xml version='1.0' encoding='utf-8' standalone='yes' ?> <v:Envelope xmlns:v='http://schemas.xmlsoap.org/soap/envelope/'> <v:Header> <b>Samsung GT-I9192</b> <c>ANDROID</c> <d>#{ANDROID_VERSION}</d> <i>#{lat}</i> <e>4.3.2</e> <f>192.168.0.200</f> <g>#{generate_token}</g> <k></k> <h>#{long}</h> <l>#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}</l> <m>8797e74f0d6eb7b1ff3dc114d4aa12d3</m> </v:Header> <v:Body> <n0:getStatus xmlns:n0='http://soap.ws.placa.service.sinesp.serpro.gov.br/'> <a>#{@plate}</a> </n0:getStatus> </v:Body> </v:Envelope>" end
configure_proxy(host, port, user, password)
click to toggle source
# File lib/sinesp_client_v2.rb, line 100 def self.configure_proxy(host, port, user, password) http_proxy(host, port,user, password) end
generate_token()
click to toggle source
# File lib/sinesp_client_v2.rb, line 57 def self.generate_token digest = OpenSSL::Digest.new('sha1') OpenSSL::HMAC.hexdigest(digest, @plate + SECRET_KEY, @plate) end
header()
click to toggle source
# File lib/sinesp_client_v2.rb, line 62 def self.header { "Timeout" => "30000", "Content-length" => body.length.to_s, "User-Agent" => "SinespCidadao / 3.0.2.1 CFNetwork / 758.2.8 Darwin / 15.0.0", "Accept" => "text/plain, */*; q=0.01", "Cache-Control" => "no-cache", "Content-Length" => "661", "Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8", "Host" => "#{BASE_URL}", "Connection" => "close" } end
lat()
click to toggle source
# File lib/sinesp_client_v2.rb, line 49 def self.lat rand(-90.000000000...90.000000000) end
long()
click to toggle source
# File lib/sinesp_client_v2.rb, line 53 def self.long rand(-180.000000000...180.000000000) end