Skip to content

Commit 2ba3aa5

Browse files
committed
add accessors for pickup, destination to Request model
- The pickup and destination locations are included in the trip details response. This adds accessors to easily access them from code after retrieving them from the trip details endpoint.
1 parent 92f3154 commit 2ba3aa5

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/uber/models/request.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Uber
22
class Request < Base
3-
attr_accessor :request_id, :status, :vehicle, :driver, :location, :eta, :surge_multiplier, :meta, :errors
3+
attr_accessor :request_id, :status, :vehicle, :driver, :location, :pickup, :destination, :eta, :surge_multiplier, :meta, :errors
44

55
def driver=(value)
66
@driver = value.nil? ? nil : Driver.new(value)
@@ -14,6 +14,14 @@ def location=(value)
1414
@location = value.nil? ? nil : Location.new(value)
1515
end
1616

17+
def pickup=(value)
18+
@pickup = value.nil? ? nil : Location.new(value)
19+
end
20+
21+
def destination=(value)
22+
@destination = value.nil? ? nil : Location.new(value)
23+
end
24+
1725
def errors=(values)
1826
@errors = values.map { |v| RequestError.new(v) }
1927
end

spec/lib/api/requests_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@
248248
"longitude" => -122.418143,
249249
"bearing" => 33
250250
},
251+
"pickup" => {
252+
"latitude" => 0.0,
253+
"longitude" => 0.5
254+
},
255+
"destination" => {
256+
"latitude" => 0.0,
257+
"longitude" => 0.6
258+
},
251259
"vehicle" => {
252260
"make" => "Bugatti",
253261
"model" => "Veyron",
@@ -276,6 +284,12 @@
276284
expect(request.location.longitude).to eql -122.418143
277285
expect(request.location.bearing).to eql 33
278286

287+
expect(request.pickup.latitude).to eql 0.0
288+
expect(request.pickup.longitude).to eql 0.5
289+
290+
expect(request.destination.latitude).to eql 0.0
291+
expect(request.destination.longitude).to eql 0.6
292+
279293
expect(request.vehicle.make).to eql 'Bugatti'
280294
expect(request.vehicle.model).to eql 'Veyron'
281295
expect(request.vehicle.license_plate).to eql 'I<3Uber'

0 commit comments

Comments
 (0)