Sha256: fa41c71ecfd1fef41ab6e9061271f5a1687f582bcbdddee9d4c9b5b73ba21ee6

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

require "net/http"
require "json"

module Vindetta
  class Api
    def self.decode(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

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.19.0 lib/vindetta/api.rb