Sha256: dfee1dd8c8d19a9b577b28b54148b089b8740351f3a6db984829b979550bb1ae

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

require "nummerplade/version"
require "open-uri"
require "json"

module Nummerplade
  class ApiClient
    attr_accessor :api_token

    def initialize api_token
      @api_token = api_token
      @url = 'http://api.nrpla.de/'
    end

    def vehicle_by_registration registration
      request(registration)
    end

    def vehicle_by_vin vin
      request("vin/" + vin)
    end

    def dmr vehicle_id
      request("dmr/" + vehicle_id)
    end

    def debt vehicle_id
      request("debt/" + vehicle_id)
    end

    def inspections vehicle_id
      request("inspections/" + vehicle_id)
    end

    private

    def request endpoint
      res = open(@url + endpoint + "?api_token=#{@api_token}&advanced=true")
      JSON.parse(res.read)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nummerplade-ruby-0.1.0 lib/nummerplade.rb