Sha256: 0b99e5caf5c1d80b26a78c8e4c91d10bf2dfe9cc033fe8f0faff3f27c8dfc3bd

Contents?: true

Size: 560 Bytes

Versions: 2

Compression:

Stored size: 560 Bytes

Contents

require "net/http"
require "json"

module Vindetta
  class Api
    def self.generate
      Net::HTTP.get("randomvin.com", "/getvin.php")

    end

    def self.get(vin)
      uri = URI("https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/#{vin}?format=json")

      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true

      request = Net::HTTP::Get.new(uri.request_uri)
      response = http.request(request)

      parse(http.request(request))
    end

    private

    def self.parse(response)
      JSON.parse(response.body)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vindetta-0.17.1 lib/vindetta/api.rb
vindetta-0.17.0 lib/vindetta/api.rb