This package provides an SDK for use with the Uber API. Currently, the following API endpoints are supported:
- Products
- Price Estimates
- Time Estimates
OAuth support for user profile and past activity access is forthcoming.
Prior to use, you'll need to need to register an application in the Uber developer portal and obtain the appropriate tokens and keys. More information about the Uber API can be found here: https://developer.uber.com/.
Full usage info can be found in the godocs.
A sample client has been included with this source that demonstrates its usage. The package import path is github.com/anweiss/uber-api-golang/uber
. The package requires the creation of a Client
type with a set of RequestOptions
. The RequestOptions
type holds the token and OAuth parameters.
import "github.com/anweiss/uber-api-golang/uber"
var options uber.RequestOptions{
ServerToken: SERVER_TOKEN
ClientId: CLIENT_ID
...
}
client := uber.Create(&options)
You can retrieve product endpoints by creating a variable which will hold the endpoint's type and required properties and pass the object Client.Get()
pl := &uber.Products{}
pl.Latitude = LAT
pl.Longitude = LONG
if e := client.Get(p1); e != nil {
log.Fatal(e)
}
The products are retrieved and stored in the Products
property.
fmt.Println("Here are the Uber options available for your area: \n")
for _, product := range pl.Products {
fmt.Println(product.DisplayName + ": " + product.Description)
}