Module: Lyft::Api::Availability

Included in:
Client
Defined in:
lib/lyft/api/availability/eta.rb,
lib/lyft/api/availability/cost.rb,
lib/lyft/api/availability/ride_types.rb,
lib/lyft/api/availability/nearby_drivers.rb

Instance Method Summary collapse

Instance Method Details

#cost(args = {}) ⇒ Object

Get Lyft costs

Examples:

client.cost start_lat: 37.7772,
            start_lng: -122.4233,
            end_lat: 37.7972,
            end_lng: -122.4533

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :start_lat (Float)

    The latitude of starting point. (required)

  • :start_lng (Float)

    The longitude of starting point. (required)

  • :end_lat (Float)

    The latitude of the end point. (required)

  • :end_lng (Float)

    The longitude of the end point. (required)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/lyft/api/availability/cost.rb', line 18

def cost(args = {})
  uri = Lyft.endpoint('/v1/cost')
  options = {
    headers: {
      Authorization: "Bearer #{public_token.access_token}"
    }.as_json,
    query: {
      start_lat: args.fetch(:start_lat),
      start_lng: args.fetch(:start_lng),
      end_lat: args.fetch(:end_lat),
      end_lng: args.fetch(:end_lng)
    }
  }

  HTTParty.get(uri, options)
end

#eta(args = {}) ⇒ Object

Get eta for lyft driver to reach location

Examples:

client.eta lat: 37.7772,
           lng: -122.4233

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lyft/api/availability/eta.rb', line 14

def eta(args = {})
  uri = Lyft.endpoint('/v1/eta')
  options = {
    headers: {
      Authorization: "Bearer #{public_token.access_token}"
    }.as_json,
    query: {
      lat: args.fetch(:lat),
      lng: args.fetch(:lng)
    }
  }

  HTTParty.get(uri, options)
end

#nearby_drivers(args = {}) ⇒ Object

Get positions of nearby drivers

Examples:

client.nearby_drivers lat: 37.7772,
                      lng: -122.4233

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lyft/api/availability/nearby_drivers.rb', line 14

def nearby_drivers(args = {})
  uri = Lyft.endpoint('/v1/drivers')
  options = {
    headers: {
      Authorization: "Bearer #{public_token.access_token}"
    }.as_json,
    query: {
      lat: args.fetch(:lat),
      lng: args.fetch(:lng)
    }
  }

  HTTParty.get(uri, options)
end

#ride_types(args = {}) ⇒ Object

Get available lyft ride types

Examples:

client.ride_types lat: 37.7772,
                  lng: -122.4233

Parameters:

  • args (Hash) (defaults to: {})

Options Hash (args):

  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lyft/api/availability/ride_types.rb', line 14

def ride_types(args = {})
  uri = Lyft.endpoint('/v1/ridetypes')
  options = {
    headers: {
      Authorization: "Bearer #{public_token.access_token}"
    }.as_json,
    query: {
      lat: args.fetch(:lat),
      lng: args.fetch(:lng)
    }
  }

  HTTParty.get(uri, options)
end