Ruby wrapper for the Geotab SDK API inspired by ActiveRecord.
Add this line to your application's Gemfile:
gem"geotab",git: "https://github.com/rarestep/geotab.git",tag: "v0.0.1"And then execute:
$ bundle
Or install it yourself as:
$ gem install geotab
Global connection configuration
Geotab.configdo |c|
c.username="<username>"c.password="<password>"c.database="<database>"c.path="myxx.geotab.com"endGeotab::Device.allOr inline connection
client=Geotab::Client.newclient.authenticate("<username>","<password>","<database>")Geotab::Device.with_connection(client).allOr inside of a block
client=Geotab::Client.newclient.authenticate("<username>","<password>","<database>")Geotab.with_connection(client)dodevices=Geotab::Device.allfault_data=Geotab::FaultDatum.allendGeotab resources are modeled after ActiveRecord models. They have access to .all, .where, .find, and .first. The where method is chainable. Next step is to add support for .update.
# Returns an array of devicesGeotab::Device.all# Returns a single deviceGeotab::StatusDatum.firstGeotab::Diagnostic.find("b1")# Where clauses are chainable. Conditions should follow Geotab SDK syntaxGeotab::Device.where({"serialNumber"=>"G7B020D3E1A4"}).where({"name"=>"07 BMW 335i"}).first# Some resources have associated resources and can be queried as suchdevice=Geotab::Device.find("b1")# Returns associated StatusData objectsdevice.status_data# Returns device's current GPS locationdevice.location=>{:date=>"2015-08-18T19:54:49.063Z",:bearing=>140,:current_state_duration=>"06:04:46.063",:is_device_communicating=>true,:is_driving=>false,:latitude=>33.511528,:longitude=>-86.8136673,:speed=>0.0}- Fork it ( https://github.com/[my-github-username]/geotab/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request