Home > Uncategorized > Our APIs are now on #RubyGems to help Ruby developers get started quickly

Our APIs are now on #RubyGems to help Ruby developers get started quickly

11090641-ruby-corazones

We’re now on RubyGems.org at https://rubygems.org/profiles/fiach – with a total of 25 Ruby Gems to be installed. They make using our Car Registration API’s Really easy to use for Ruby Developers

Just type:

gem install CarRegistrationUKirb

(Replacing “UK” with any other country we support)

Then, type;

require(“CarRegistrationUK”)

data = CarRegistrationUK.Lookup(“SL14MKM”,”**username**”,”**password**”)

  • Obviously, you need to get your own username and password from RegCheck.org.uk – and SL14MKM is just a sample plate.

And get an object array back such as;

{“ABICode”=>”18503204”,
“Description”=>”2014 Ford Mondeo Titanium X Business Edit Tdci 140, 1997CC Diesel, 5DR, Manual”,
“RegistrationYear”=>”2014”,
“CarMake”=>{“CurrentTextValue”=>”Ford”},
“CarModel”=>{“CurrentTextValue”=>”Mondeo”},
“EngineSize”=>{“CurrentTextValue”=>”1997CC”},
“FuelType”=>{“CurrentTextValue”=>”Diesel”},
“MakeDescription”=>”Ford”,
“ModelDescription”=>”Mondeo”,
“Immobiliser”=>{“CurrentTextValue”=>””},
“NumberOfSeats”=>{“CurrentTextValue”=>5},
“IndicativeValue”=>{“CurrentTextValue”=>””},
“DriverSide”=>{“CurrentTextValue”=>”RHD”},
“Transmission”=>{“CurrentTextValue”=>”Manual”},
“NumberOfDoors”=>{“CurrentTextValue”=>”5”},
“ImageUrl”=>”http://www.regcheck.org.uk/image.aspx/@Rm9yZCBNb25kZW8=”,
“VehicleInsuranceGroup”=>”19”}

You can access any property of this like so

data[“Description”]

Giving –

“2014 Ford Mondeo Titanium X Business Edit Tdci 140, 1997CC Diesel, 5DR, Manual”

For those interested in looking under the hood, here is the source code of the Ruby Gem itself ;

require “open-uri”
require “json”

class CarRegistrationLookupError < StandardError def initialize(msg=”Unknown error”) super end end class CarRegistrationUK def self.Lookup(registrationNumber,username,password) begin @data = open(“https://www.regcheck.org.uk/api/json.aspx/Check/&#8221; + registrationNumber,http_basic_authentication: [username, password]).read rescue OpenURI::HTTPError => error
raise CarRegistrationLookupError, error.io.string
end
return JSON.parse(@data)
end
end

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: