Class: Lyft::Client::Api::Availability

Inherits:
Base
  • Object
show all
Defined in:
lib/lyft/client/api/availability.rb

Constant Summary collapse

ENDPOINTS =
{
  cost: "/#{API_VERSION}/cost",
  eta: "/#{API_VERSION}/eta",
  nearby_drivers: "/#{API_VERSION}/drivers",
  ride_types: "/#{API_VERSION}/ridetypes"
}

Constants inherited from Base

Base::API_VERSION, Base::DEFAULT_VALIDATES

Instance Method Summary collapse

Methods inherited from Base

#initialize, #path_for, path_for, #set_debug_output

Constructor Details

This class inherits a constructor from Lyft::Client::Api::Base

Instance Method Details

#cost(args = {}) ⇒ Object

Get the estimated cost of ride.

Examples:

Get the estimated cost of a ride.

client.availability.cost(
  start_lat: 37.7772,
  start_lng: -122.4233,
  end_lat: 37.7972,
  end_lng: -122.4533,
  access_token: 'token'
)

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :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)



31
32
33
34
35
36
37
38
# File 'lib/lyft/client/api/availability.rb', line 31

def cost(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:cost),
    access_token: args.delete(:access_token),
    options: { query: args }
  )
end

#eta(args = {}) ⇒ Object

Get eta for lyft driver to reach location

Examples:

Get lyft eta to a specified location.

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

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



53
54
55
56
57
58
59
60
# File 'lib/lyft/client/api/availability.rb', line 53

def eta(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:eta),
    access_token: args.delete(:access_token),
    options: { query: args }
  )
end

#nearby_drivers(args = {}) ⇒ Object

Get positions of nearby drivers

Examples:

Get location of nearby drivers.

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

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



75
76
77
78
79
80
81
82
# File 'lib/lyft/client/api/availability.rb', line 75

def nearby_drivers(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:nearby_drivers),
    access_token: args.delete(:access_token),
    options: { query: args }
  )
end

#ride_types(args = {}) ⇒ Object

Get available lyft ride types

Examples:

Get available ride types for a location.

client.availability.ride_types lat: 37.7772,
                               lng: -122.4233

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :lat (Float)

    The latitude of pickup. (required)

  • :lng (Float)

    The longitude of pickup. (required)



96
97
98
99
100
101
102
103
# File 'lib/lyft/client/api/availability.rb', line 96

def ride_types(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:nearby_drivers),
    access_token: args.delete(:access_token),
    options: { query: args }
  )
end