ericskiff / safer_bus_api

A simple wrapper for the SaferBusAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gem Version

Overview

The Department of Transportation maintains the SaferBusAPI to provide safety information pertaining to transporation companies. Information related to this API and instructions for access the API can be found here: https://mobile.fmcsa.dot.gov/developer/apidescription.page?cid=561

Installation

Add this line to your application's Gemfile:

gem 'safer_bus_api'

Then run:

bundle install

Configuration

Set your api_token obtained from registering at https://mobile.fmcsa.dot.gov/developer/UserAccountCreate.page

Note: Once registered you will be emailed a registration token which you can then use to complete your registration and obtain an api token for your application

SaferBusApi.configure do |config|
  config.api_token = 'your-token-here'
end

Example Usage

Query by DOT number:

  request = SaferBusApi::Request.new(dot_number: '44110')
  response = request.perform
  response.data # Returns a formatted hash
  response.raw_data # Returns the raw response from 

Query by Company Name:

  request = SaferBusApi::Request.new(company_name: 'greyhound') # Note: company name should have no spaces and be all lower case.
  response = request.perform
  response.data # Returns a formatted hash

Query by MC Number:

  request = SaferBusApi::Request.new(mc_number: '1515') # Note: company name should have no spaces and be all lower case.
  response = request.perform
  response.data # Returns a formatted hash

Author

Nathan Bertram

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Ensure tests are passing with rspec
  4. Commit your changes (git commit -am 'Added some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request
  7. You da man!

About

A simple wrapper for the SaferBusAPI

License:MIT License


Languages

Language:Ruby 100.0%