location-service-client
A gem for clients of Springshot's location service
Installation
Add it to your gemfile.
gem 'location-service-client', git: 'https://8bcbcee566e5e7a5d75592940d15bc9f68b84bd9:[email protected]/springshot/location-service-client.git'
Configuration
Settings.location_service (c.f. the 'config' gem) will need a url for the location service and the app token configured to access the locations end point.
location_service
url: ...
token: ...
Documentation
The location service client just adds a dead simple Location class that presently downloads a big array of nested hashes (with indifferent access and the keys snake-cased) of all locations in the location service and some helper methods.
> Location.all
=> [{"id"=>449, "name"=>"Hartsfield-Jackson Atlanta International Airport", "code"=>"ATL", "kind"=>"airport", "lat"=>33.640067, "lng"=>-84.44403, "parent_location_id"=>nil, "created_at"=>"2016-04-28T21:19:02.658Z", "updated_at"=>"2016-04-28T21:19:02.658Z", "beacons"=>[], "child_locations"=>[..]},...]
There are some top level methods for accessing that data:
Location.find(id) -> find the location by its location service ID.
Location.find_by_code(code) -> return the hash of the location with the code (e.g. an airport's IATA code or a gate's qr_code).
Location.parents -> return just the roots of the trees
And until it needs to do more that's all it does.
Contributing
Make sure any backwards incompatible changes come with a version bump so existing projects aren't obliterated.