-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver: implement trips from the new API
Updates #49 Implements method - DriverTrips which correlates with https://developer.uber.com/docs/drivers/references/api/v1/partners-trips-get and allows one to query for driver trips within a period or paginate within them. * Also refactored to reuse DriverPayments which only varies from DriverTrips by populating Payments instead of Trips; the rest of the pagination and usage is the same Sample usage ```go package main import ( "fmt" "log" "os" "time" "github.com/orijtech/uber/v1" ) func main() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } aWeekAgo := time.Now().Add(-1 * time.Hour * 7 * 24) yesterday := time.Now().Add(-1 * time.Hour * 24) trips, err := client.ListDriverTrips(&uber.DriverInfoQuery{ StartDate: &aWeekAgo, EndDate: &yesterday, MaxPageNumber: 2, Offset: 4, }) if err != nil { log.Fatal(err) } for page := range trips.Pages { if page.Err != nil { fmt.Printf("%d err: %v\n", page.PageNumber, page.Err) continue } for i, trip := range page.Trips { fmt.Printf("\t%d:: DriverID: %q\nFare: %.2f\n%#v\n", i, trip.DriverID, trip.Fare, trip) } fmt.Println() } } ```
- Loading branch information
Showing
10 changed files
with
671 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"count": 1200, | ||
"limit": 2, | ||
"trips": [ | ||
{ | ||
"fare": 6.2, | ||
"dropoff": { | ||
"timestamp": 1502844378 | ||
}, | ||
"vehicle_id": "0082b54a-6a5e-4f6b-b999-b0649f286381", | ||
"distance": 0.37, | ||
"start_city": { | ||
"latitude": 38.3498, | ||
"display_name": "Charleston, WV", | ||
"longitude": -81.6326 | ||
}, | ||
"status_changes": [ | ||
{ | ||
"status": "accepted", | ||
"timestamp": 1502843899 | ||
}, | ||
{ | ||
"status": "driver_arrived", | ||
"timestamp": 1502843900 | ||
}, | ||
{ | ||
"status": "trip_began", | ||
"timestamp": 1502843903 | ||
}, | ||
{ | ||
"status": "completed", | ||
"timestamp": 1502844378 | ||
} | ||
], | ||
"surge_multiplier": 1, | ||
"pickup": { | ||
"timestamp": 1502843903 | ||
}, | ||
"driver_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==", | ||
"status": "completed", | ||
"duration": 475, | ||
"trip_id": "b5613b6a-fe74-4704-a637-50f8d51a8bb1", | ||
"currency_code": "USD" | ||
}, | ||
{ | ||
"fare": 8.2, | ||
"dropoff": { | ||
"timestamp": 1502846443 | ||
}, | ||
"vehicle_id": "f227de83-0f6a-4422-a733-1e8b781b6ff7", | ||
"distance": 2.11, | ||
"start_city": { | ||
"latitude": 38.3498, | ||
"display_name": "Charleston, WV", | ||
"longitude": -81.6326 | ||
}, | ||
"status_changes": [ | ||
{ | ||
"status": "accepted", | ||
"timestamp": 1502844744 | ||
}, | ||
{ | ||
"status": "driver_arrived", | ||
"timestamp": 1502843900 | ||
}, | ||
{ | ||
"status": "trip_began", | ||
"timestamp": 1502843903 | ||
}, | ||
{ | ||
"status": "completed", | ||
"timestamp": 1502844378 | ||
} | ||
], | ||
"surge_multiplier": 1.93, | ||
"pickup": { | ||
"timestamp": 1502843903 | ||
}, | ||
"driver_id": "8LvWuRAq2511gmr8EMkovekFNa2848lyMaQevIto-aXmnK9oKNRtfTxYLgPq9OSt8EzAu5pDB7XiaQIrcp-zXgOA5EyK4h00U6D1o7aZpXIQah--U77Eh7LEBiksj2rahB==", | ||
"status": "completed", | ||
"duration": 475, | ||
"trip_id": "b5613b6a-fe74-4704-a637-50f8d51a8bb1", | ||
"currency_code": "USD" | ||
} | ||
], | ||
"offset": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Oops, something went wrong.