Class: Lyft::Client::Api::Rides

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

Constant Summary collapse

ENDPOINTS =
{
  request: "/#{API_VERSION}/rides",
  details: "/#{API_VERSION}/rides/{{ride_id}}",
  cancel: "/#{API_VERSION}/rides/{{ride_id}}/cancel",
  rating: "/#{API_VERSION}/rides/{{ride_id}}/rating",
  receipt: "/#{API_VERSION}/rides/{{ride_id}}/receipt",
  destination: "/#{API_VERSION}/rides/{{ride_id}}/destination",
  sandbox_primetime: "/#{API_VERSION}/sandbox/primetime",
  sandbox_rides: "/#{API_VERSION}/sandbox/rides/{{ride_id}}",
  sandbox_ridetypes: "/#{API_VERSION}/sandbox/ridetypes/{{ride_type}}"
}

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

#cancel(args = {}) ⇒ Object

Cancel a ride request.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_id (String) — default: *required*
  • :cancel_confirmation_token (String)

See Also:



28
29
30
31
32
33
34
35
# File 'lib/lyft/client/api/rides.rb', line 28

def cancel(args = {})
  make_request(
    http_method: :post,
    endpoint: path_for(:cancel, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#destination(args = {}) ⇒ Object

Update the ride destination

Parameters:

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

Options Hash (args):

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

See Also:



48
49
50
51
52
53
54
55
# File 'lib/lyft/client/api/rides.rb', line 48

def destination(args = {})
  make_request(
    http_method: :put,
    endpoint: path_for(:destination, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#details(args = {}) ⇒ Object

Get details of a ride.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_id (String)

    The ride id. (required)

See Also:



65
66
67
68
69
70
71
# File 'lib/lyft/client/api/rides.rb', line 65

def details(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:details, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token)
  )
end

#rate(args = {}) ⇒ Object Also known as: tip

Rate a ride and/or provide a tip.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_id (String) — default: *required*
  • :rating (Integer)

    Rating should be between 1 and 5 inclusive. (required)

  • :tip (Hash)

    The tip should include :amount and :currency.

  • :feedback (String)

See Also:



84
85
86
87
88
89
90
91
# File 'lib/lyft/client/api/rides.rb', line 84

def rate(args = {})
  make_request(
    http_method: :put,
    endpoint: path_for(:rating, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#receipt(args = {}) ⇒ Object

Get receipt for ride

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_id (String) — default: *required*

See Also:



102
103
104
105
106
107
108
# File 'lib/lyft/client/api/rides.rb', line 102

def receipt(args = {})
  make_request(
    http_method: :get,
    endpoint: path_for(:receipt, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token)
  )
end

#request(args = {}) ⇒ Object

Request a ride.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :origin (Hash)

    The origin should contain :lat and :lng

  • :destination (Hash)

    The destination should contain :lat and :lng.

  • :ride_type (String)
  • :primetime_confirmation_token (String)

See Also:



121
122
123
124
125
126
127
128
# File 'lib/lyft/client/api/rides.rb', line 121

def request(args = {})
  make_request(
    http_method: :post,
    endpoint: path_for(:request),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#set_driver_availability(args = {}) ⇒ Object

Set driver availability for a ride type in an area.

Parameters:

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

    a customizable set of options

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_type (String) — default: *required*
  • :lat (Float) — default: *required*
  • :lng (Float) — default: *required*
  • :driver_availability (Boolean)

Raises:

  • (RuntimeError)

    Raises if not in sandbox mode.

  • (ArgumentError)

    Raises if invalid ride type.



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/lyft/client/api/rides.rb', line 210

def set_driver_availability(args = {})
  validate_sandboxed
  raise ArgumentError, 'Invalid Ride Type' unless Lyft::Ride::RIDE_TYPES.include? args[:ride_type]

  make_request(
    http_method: :put,
    endpoint: path_for(:sandbox_ridetypes, ride_type: args.delete(:ride_type)),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#set_primetime(args = {}) ⇒ Object

Set the primetime percentage in area

Examples:

Set the prime time percentage.

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

Parameters:

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

Options Hash (args):

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

Raises:

  • (RuntimeError)

    Raises if not in sandbox mode.



188
189
190
191
192
193
194
195
196
# File 'lib/lyft/client/api/rides.rb', line 188

def set_primetime(args = {})
  validate_sandboxed
  make_request(
    http_method: :put,
    endpoint: path_for(:sandbox_primetime),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#set_ridetypes(args = {}) ⇒ Object

Preset the ridetypes in area.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :lat (Float) — default: *required*
  • :lng (Float) — default: *required*
  • :ride_types (Array<String>)

    The ride types to make available. Accepted values are ‘lyft’, ‘lyft_line’, ‘lyft_plus’, and ‘lyft_suv’.

Raises:

  • (RuntimeError)

    Raises if not in sandbox mode.



141
142
143
144
145
146
147
148
149
# File 'lib/lyft/client/api/rides.rb', line 141

def set_ridetypes(args = {})
  validate_sandboxed
  make_request(
    http_method: :put,
    endpoint: path_for(:sandbox_ridetypes),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end

#set_status(args = {}) ⇒ Object

Propogate ride through different states.

Parameters:

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

Options Hash (args):

  • :access_token (String) — default: *required*
  • :ride_id (String) — default: *required*
  • :status (String)

    The status of the ride

Raises:

  • (RuntimeError)

    Raises if not in sandbox mode.



160
161
162
163
164
165
166
167
168
# File 'lib/lyft/client/api/rides.rb', line 160

def set_status(args = {})
  validate_sandboxed
  make_request(
    http_method: :put,
    endpoint: path_for(:sandbox_rides, ride_id: args.delete(:ride_id)),
    access_token: args.delete(:access_token),
    options: { body: args.to_json }
  )
end