Skip to content

skukx/rlyft

Repository files navigation

RLyft

Gem Version CircleCI

Simple wrapper for interacting with Lyft's public api.

Breaking Changes

See #6

Installation

Add this line to your application's Gemfile:

gem 'rlyft', require 'lyft'

And then execute:

$ bundle

Setup

client = Lyft::Client.new(
  client_id: 'client_id',
  client_secret: 'client_secret',
  use_sandbox: true
)

Using Public Api

Get Access Token:

# Public token
client.oauth.retrieve_access_token

# When using oauth.
client.oauth.retrieve_access_token authorization_code: 'auth_code'

Calculate Lyft cost.

client.availability.cost access_token: 'access_token',
                         params: {
                           start_lat: 37.7772,
                           start_lng: -122.4233,
                           end_lat: 37.7972,
                           end_lng: -122.4533
                         }

Time for nearest driver to reach location.

client.availability.eta access_token: 'token',
                        params: {
                          lat: 37.7772,
                          lng: -122.4233
                        }

Get the location of nearby drivers.

client.availability.nearby_drivers access_token: 'token',
                                   params: {
                                     lat: 37.7772,
                                     lng: -122.4233
                                   }

Get available ride types.

client.availability.ride_types access_token: 'token',
                               params: {
                                 lat: 37.7772,
                                 lng: -122.4233
                               }

Request a ride

client.rides.request access_token: 'token',
                     params: {
                       origin: { lat: 37.7772, lng: -122.4233 },
                       ride_type: Lyft::Ride::Type::LYFT
                     }

Cancel a ride

client.rides.cancel access_token: 'token',
                    params: { ride_id: '123' }

# When cancel_confirmation_token is needed.
client.rides.cancel access_token: 'token',
                    params: {
                      ride_id: '123',
                      cancel_confirmation_token: 'cancellation_token'
                    }

Using the Sandbox:

Set available ride types

client.rides.set_ridetypes(
  access_token: 'my_token',
  params: {
    lat: 37.7833,
    lng: -122.4167,
    ride_types: [
      Lyft::Ride::Type::LYFT,
      Lyft::Ride::Type::LYFT_PLUS
    ]
  }
)

Set ride status

client.rides.set_status(
  access_token: 'my_token',
  params: {
    ride_id: 'my_ride_id',
    status: Lyft::Ride::Status::ACCEPTED
  }
)

Set driver availability

client.rides.set_driver_availability(
  access_token: 'my_token',
  params: {
    ride_type: Lyft::Ride::Type::LYFT_SUV
    lat: 37.7833,
    lng: -122.4167,
    driver_availability: true
  }
)

Set primetime percentage

client.rides.set_primetime(
  access_token: 'my_token',
  params: {
    lat: 37.7833,
    lng: -122.4167,
    primetime_percentage: '25%'
  }
)

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/skukx/lyft.

License

The gem is available as open source under the terms of the MIT License.

About

(rlyft) Ruby Wrapper for Lyft API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published