elixir_uber v0.0.2 ElixirUber

Provides access to the Uber API.

Summary

Functions

Returns the url you will need to redirect a user to for them to authorise your app with their Uber account. When they log in there, you will need to implement a way to catch the code in the request url (they will be redirected back to your UBER_REDIRECT_URI)

Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom to request from Uber

Initialises ElixirUber with system environment variables. For this to work, set UBER_CLIENT_ID, UBER_CLIENT_SECRET and UBER_REDIRECT_URI

Sets a global user authentication token, this is useful for scenarios where your app will only ever make requests on behalf of one user at a time

Initialises and configures ElixirUber with a client_id, client_secret and redirect_uri. If you’re not doing anything particularly interesting here, it’s better to set them as environment variables and use ElixirUber.configure/0

Takes a keyword list containing the code returned from Uber in the redirect after login and returns a {:ok, access_token} for making authenticated requests. If you pass an incorrect code, it will return you an {:error, reason}

Takes a token and returns a %ElixirUber.Model.User

Functions

authorize_url!()

Returns the url you will need to redirect a user to for them to authorise your app with their Uber account. When they log in there, you will need to implement a way to catch the code in the request url (they will be redirected back to your UBER_REDIRECT_URI).

authorize_url!(scope)

Returns the url to redirect a user to when authorising your app to use their account. Takes a list of permissions scopes as atom to request from Uber.

Available scopes: :profile, :places, :ride_widgets, :history_lite, :history

configure()

Initialises ElixirUber with system environment variables. For this to work, set UBER_CLIENT_ID, UBER_CLIENT_SECRET and UBER_REDIRECT_URI.

Example

UBER_CLIENT_ID=XXXX UBER_CLIENT_SECRET=XXXX UBER_REDIRECT_URI=localhost
iex(1)> ElixirUber.configure
{:ok, []}
configure(scope, token)

Sets a global user authentication token, this is useful for scenarios where your app will only ever make requests on behalf of one user at a time.

configure(client_id, client_secret, redirect_uri)

Initialises and configures ElixirUber with a client_id, client_secret and redirect_uri. If you’re not doing anything particularly interesting here, it’s better to set them as environment variables and use ElixirUber.configure/0

Example

iex(1)> ElixirUber.configure("XXXX", "XXXX", "localhost:4000")
{:ok, []}
get_token!(code)

Takes a keyword list containing the code returned from Uber in the redirect after login and returns a {:ok, access_token} for making authenticated requests. If you pass an incorrect code, it will return you an {:error, reason}

me(token)

Takes a token and returns a %ElixirUber.Model.User.