uber-sdk

A Ruby SDK for the Uber API.


License
MIT
Install
gem install uber-sdk -v 0.1.1

Documentation

Uber

Golang bindings for Uber API

Build Status GoDoc

Getting Started

1º Install twilio

$ go get github.com/chrisenytc/uber

Documentation

For more information about using this library, view the Godocs.

Usage

Register Your Application

In order to use the Uber API you must register an application at the Uber Developer Portal. In turn you will receive a client_id, secret, and server_token.

Creating a Client

package main

import (
  uber "github.com/chrisenytc/uber"
)

func main() {
	client := uber.NewClient(SERVER_TOKEN)
}

Making Requests

Currently, the Uber API offers support for requesting information about products (e.g available cars), price estimates, time estimates, user ride history, and user info. All requests require a valid server_token. Requests that require latitude or longitude as arguments are float64's (and should be valid lat/lon's).

products, err := client.GetProducts(37.7759792, -122.41823)
if err != nil {
	fmt.Println(err)
} else {
	for _, product := range products {
		fmt.Println(*product)
	}
}

prices, err := client.GetPrices(41.827896, -71.393034, 41.826025, -71.406892)
if err != nil {
	fmt.Println(err)
} else {
	for _, price := range prices {
		fmt.Println(*price)
	}
}

Authorizing

Uber's OAuth 2.0 flow requires the user go to URL they provide.

You can generate this URL programatically by doing:

url, _ := client.OAuth(
	CLIENT_ID, CLIENT_SECRET, REDIRECT_URL, "profile",
)

After the user goes to url and grants your application permissions, you need to figure out a way for the user to input the second argument of the url to which they are redirected (ie: REDIRECT_URL/?state=go-uber&code=AUTH_CODE). You then need to

client.SetAccessToken(AUTH_CODE)

Or you can automate the whole process by:

err := client.AutOAuth(
	CLIENT_ID, CLIENT_SECRET, REDIRECT_URL, "profile",
)

At which point, feel free to

profile, err := client.GetUserProfile()
if err != nil {
	fmt.Println(err)
} else {
	fmt.Println(profile)
}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/chrisenytc/uber. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

  1. Fork it chrisenytc/uber
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature")
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Support

If you have any problem or suggestion please open an issue here.

Credits

This is a fork of the project r-medina/go-uber. Give some respect to him.

License

Check here.