-
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
products: implement ride products retrieval #38
Comments
odeke-em
added a commit
that referenced
this issue
Jun 24, 2017
Fixes #38. a) Implements ListProducts, which given a place (lat, lon) lists available products b) Implements ProductByID c) Cleans up authentication problems that I noticed while testing out a bunch of client methods. Added "Content-Type": "application/json" headers for PUT and POST. Exhibits: * ProductByID: ```go func Example_client_ProductByID() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } product, err := client.ProductByID("bc300c14-c30d-4d3f-afcb-19b240c16a13") if err != nil { log.Fatal(err) } fmt.Printf("The Product information: %#v\n", product) } ``` Giving ```shell The Product information: &uber.Product{UpfrontFareEnabled:true, Capacity:2, ID:"bc300c14-c30d-4d3f-afcb-19b240c16a13", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberpool-2.png", CashEnabled:false, Shared:true, ShortDescription:"uberPOOL", DisplayName:"POOL", Description:"Share the ride, share the cost"} ``` * ListProducts: ```go func Example_client_ListProducts() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } products, err := client.ListProducts(&uber.Place{ Latitude: 38.8971, Longitude: -77.0366, }) if err != nil { log.Fatal(err) } for i, product := range products { fmt.Printf("#%d: ID: %q Product: %#v\n", i, product.ID, product) } } ``` Produces ```shell &uber.Product{UpfrontFareEnabled:true, Capacity:2, ID:"bc300c14-c30d-4d3f-afcb-19b240c16a13", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberpool-2.png", CashEnabled:false, Shared:true, ShortDescription:"uberPOOL", DisplayName:"POOL", Description:"Share the ride, share the cost"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"dee8691c-8b48-4637-b048-300eee72d58d", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png", CashEnabled:false, Shared:false, ShortDescription:"uberX", DisplayName:"uberX", Description:"The low-cost Uber"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"9ffa937e-7d2e-4bcf-bc2b-ffec4ef24380", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberxl2.png", CashEnabled:false, Shared:false, ShortDescription:"uberXL", DisplayName:"uberXL", Description:"Low-cost rides for large groups"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"bc98a16f-ad72-41a3-8624-809ce654ac57", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"uberX + Car Seat", DisplayName:"uberX + Car Seat", Description:"uberX + Car Seat"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"a52a9012-d73e-4127-8440-f273cddfd307", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-black.png", CashEnabled:false, Shared:false, ShortDescription:"BLACK CAR", DisplayName:"UberBLACK", Description:"The Original Uber"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"2a299c73-098d-47cd-b32c-825cb155f82a", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"BLACK CAR + Car Seat", DisplayName:"BLACK CAR + Car Seat", Description:"BLACK CAR + Car Seat"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"4e6fd14c-3866-40f1-b173-f12aeb8fbbd0", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-suv.png", CashEnabled:false, Shared:false, ShortDescription:"SUV", DisplayName:"UberSUV", Description:"Room for everyone"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"74766497-b951-4eae-98c9-a67d87e2c0c4", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"SUV + Car Seat", DisplayName:"SUV + Car Seat", Description:"SUV + Car Seat"} &uber.Product{UpfrontFareEnabled:false, Capacity:4, ID:"89f38d7a-d184-4054-9f2e-6b57c94143d6", PriceDetails:(*uber.PriceDetails)(0xc4201d8120), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png", CashEnabled:false, Shared:false, ShortDescription:"Wheelchair", DisplayName:"Wheelchair", Description:"TAXI WITHOUT THE HASSLE"} &uber.Product{UpfrontFareEnabled:false, Capacity:4, ID:"f67c83fb-4668-42eb-9aa1-ab32e710c8bf", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-taxi.png", CashEnabled:false, Shared:false, ShortDescription:"TAXI", DisplayName:"uberTAXI", Description:"Taxi without the hassle"} ```
Implemented by #39. |
odeke-em
added a commit
that referenced
this issue
Jun 24, 2017
Fixes #38. a) Implements ListProducts, which given a place (lat, lon) lists available products b) Implements ProductByID c) Cleans up authentication problems that I noticed while testing out a bunch of client methods. Added "Content-Type": "application/json" headers for PUT and POST. Exhibits: * ProductByID: ```go func Example_client_ProductByID() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } product, err := client.ProductByID("bc300c14-c30d-4d3f-afcb-19b240c16a13") if err != nil { log.Fatal(err) } fmt.Printf("The Product information: %#v\n", product) } ``` Giving ```shell The Product information: &uber.Product{UpfrontFareEnabled:true, Capacity:2, ID:"bc300c14-c30d-4d3f-afcb-19b240c16a13", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberpool-2.png", CashEnabled:false, Shared:true, ShortDescription:"uberPOOL", DisplayName:"POOL", Description:"Share the ride, share the cost"} ``` * ListProducts: ```go func Example_client_ListProducts() { client, err := uber.NewClientFromOAuth2File(os.ExpandEnv("$HOME/.uber/credentials.json")) if err != nil { log.Fatal(err) } products, err := client.ListProducts(&uber.Place{ Latitude: 38.8971, Longitude: -77.0366, }) if err != nil { log.Fatal(err) } for i, product := range products { fmt.Printf("#%d: ID: %q Product: %#v\n", i, product.ID, product) } } ``` Produces ```shell &uber.Product{UpfrontFareEnabled:true, Capacity:2, ID:"bc300c14-c30d-4d3f-afcb-19b240c16a13", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberpool-2.png", CashEnabled:false, Shared:true, ShortDescription:"uberPOOL", DisplayName:"POOL", Description:"Share the ride, share the cost"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"dee8691c-8b48-4637-b048-300eee72d58d", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png", CashEnabled:false, Shared:false, ShortDescription:"uberX", DisplayName:"uberX", Description:"The low-cost Uber"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"9ffa937e-7d2e-4bcf-bc2b-ffec4ef24380", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberxl2.png", CashEnabled:false, Shared:false, ShortDescription:"uberXL", DisplayName:"uberXL", Description:"Low-cost rides for large groups"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"bc98a16f-ad72-41a3-8624-809ce654ac57", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"uberX + Car Seat", DisplayName:"uberX + Car Seat", Description:"uberX + Car Seat"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"a52a9012-d73e-4127-8440-f273cddfd307", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-black.png", CashEnabled:false, Shared:false, ShortDescription:"BLACK CAR", DisplayName:"UberBLACK", Description:"The Original Uber"} &uber.Product{UpfrontFareEnabled:true, Capacity:4, ID:"2a299c73-098d-47cd-b32c-825cb155f82a", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"BLACK CAR + Car Seat", DisplayName:"BLACK CAR + Car Seat", Description:"BLACK CAR + Car Seat"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"4e6fd14c-3866-40f1-b173-f12aeb8fbbd0", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-suv.png", CashEnabled:false, Shared:false, ShortDescription:"SUV", DisplayName:"UberSUV", Description:"Room for everyone"} &uber.Product{UpfrontFareEnabled:true, Capacity:6, ID:"74766497-b951-4eae-98c9-a67d87e2c0c4", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-family.png", CashEnabled:false, Shared:false, ShortDescription:"SUV + Car Seat", DisplayName:"SUV + Car Seat", Description:"SUV + Car Seat"} &uber.Product{UpfrontFareEnabled:false, Capacity:4, ID:"89f38d7a-d184-4054-9f2e-6b57c94143d6", PriceDetails:(*uber.PriceDetails)(0xc4201d8120), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png", CashEnabled:false, Shared:false, ShortDescription:"Wheelchair", DisplayName:"Wheelchair", Description:"TAXI WITHOUT THE HASSLE"} &uber.Product{UpfrontFareEnabled:false, Capacity:4, ID:"f67c83fb-4668-42eb-9aa1-ab32e710c8bf", PriceDetails:(*uber.PriceDetails)(nil), ImageURL:"http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-taxi.png", CashEnabled:false, Shared:false, ShortDescription:"TAXI", DisplayName:"uberTAXI", Description:"Taxi without the hassle"} ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Implement:
These methods are necessary for #31 to be completed
The text was updated successfully, but these errors were encountered: