-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deliveries/rush: implement the UberRush API #32
Labels
Comments
Methods:
|
odeke-em
added a commit
that referenced
this issue
Jun 21, 2017
Updates #32 Implements a client method to request a delivery. Note: this method requires OAuth2.0 authentication so make sure to use the appropriate OAuth2.0 powered transport. * Exhibit: ```go package main import ( "fmt" "log" "github.com/orijtech/uber/v1" ) func main() { client, err := uber.NewClientFromOAuth2File("./testdata/.uber/credentials.json") if err != nil { log.Fatal(err) } deliveryConfirmation, err := client.RequestDelivery(&uber.DeliveryRequest{ Pickup: &uber.Endpoint{ Contact: &uber.Contact{ CompanyName: "orijtech", Email: "[email protected]", SendSMSNotifications: true, }, Location: &uber.Location{ PrimaryAddress: "Empire State Building", State: "NY", Country: "US", }, SpecialInstructions: "Please ask guest services for \"I Man\"", }, Dropoff: &uber.Endpoint{ Contact: &uber.Contact{ FirstName: "delivery", LastName: "bot", CompanyName: "Uber", SendEmailNotifications: true, }, Location: &uber.Location{ PrimaryAddress: "530 W 113th Street", SecondaryAddress: "Floor 2", Country: "US", PostalCode: "10025", State: "NY", }, }, Items: []*uber.Item{ { Title: "phone chargers", Quantity: 10, }, { Title: "Blue prints", Fragile: true, Quantity: 1, }, }, }) if err != nil { log.Fatal(err) } log.Printf("The confirmation: %+v\n", deliveryConfirmation) } ```
odeke-em
added a commit
that referenced
this issue
Jun 21, 2017
Updates #32 Cancel a delivery by means of the delivery ID. There are limitations however on when a cancellation can be made. See more information at https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-cancel-post * Exhibit: ```go func cancelDelivery() { client, err := uber.NewClientFromOAuth2File("./testdata/.uber/credentials.json") if err != nil { log.Fatal(err) } err := client.CancelDelivery("71a969ca-5359-4334-a7b7-5a1705869c51") if err == nil { log.Printf("Successfully canceled that delivery!") } else { log.Printf("Failed to cancel that delivery, err: %v", err) } } ```
odeke-em
added a commit
that referenced
this issue
Jul 5, 2017
Updates #32 Implemented Client.ListDeliveries. Sample usage: ```go func main() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } delivRes, err := client.ListDeliveries(&uber.DeliveryListRequest{ Status: uber.StatusCompleted, StartOffset: 20, }) if err != nil { log.Fatal(err) } itemCount := uint64(0) for page := range delivRes.Pages { if page.Err != nil { fmt.Printf("Page #%d err: %v", page.PageNumber, page.Err) } for i, delivery := range page.Deliveries { fmt.Printf("\t(%d): %#v\n", i, delivery) itemCount += 1 } if itemCount >= 10 { delivRes.Cancel() } } } ```
odeke-em
added a commit
that referenced
this issue
Jul 5, 2017
Updates #32 * Implemented Client.ListDeliveries. * Introduced scope oauth2.ScopeDelivery. NB: * ListDeliveries hits the /v1 API instead of /v1.2 Sample usage: ```go func main() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } delivRes, err := client.ListDeliveries(&uber.DeliveryListRequest{ Status: uber.StatusCompleted, StartOffset: 20, }) if err != nil { log.Fatal(err) } itemCount := uint64(0) for page := range delivRes.Pages { if page.Err != nil { fmt.Printf("Page #%d err: %v", page.PageNumber, page.Err) } for i, delivery := range page.Deliveries { fmt.Printf("\t(%d): %#v\n", i, delivery) itemCount += 1 } if itemCount >= 10 { delivRes.Cancel() } } } ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The UberRush API allows for food deliveries. Once the functionality is in with a couple of methods of making this possible, it opens up the possibility for this API client to be useable for one off apps e.g a food ordering and delivery app. Given that uberhook has already been implemented, it should become easier to assemble the pieces in order to build a food delivery app and also get notifications of different webhook events.
The text was updated successfully, but these errors were encountered: