elixir_uber v0.0.6 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.History with a rides history

Takes a limit, offset, token and returns a %ElixirUber.Model.History with a rides history

Takes a token and returns a %ElixirUber.Model.Me with basic user info

Takes a token and returns a %ElixirUber.Model.PaymentMethods with available payment methods

Takes a place_id, token and returns a %ElixirUber.Model.Places with favorite work and home addresses. place_id parameter should be ‘work’ or ‘home’

Takes a latitude, longitude, token and returns a %ElixirUber.Model.Products with available products list

Takes a request_id and returns a %ElixirUber.Model.Receipt with ride receipt details

Takes a request_id and returns a %ElixirUber.Model.Request with request details

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}

history(token)

Takes a token and returns a %ElixirUber.Model.History with a rides history.

history(limit, offset, token)

Takes a limit, offset, token and returns a %ElixirUber.Model.History with a rides history.

me(token)

Takes a token and returns a %ElixirUber.Model.Me with basic user info

payment_methods(token)

Takes a token and returns a %ElixirUber.Model.PaymentMethods with available payment methods.

places(place_id, token)

Takes a place_id, token and returns a %ElixirUber.Model.Places with favorite work and home addresses. place_id parameter should be ‘work’ or ‘home’

products(latitude, longitude, token)

Takes a latitude, longitude, token and returns a %ElixirUber.Model.Products with available products list.

receipt(request_id, token)

Takes a request_id and returns a %ElixirUber.Model.Receipt with ride receipt details.

request(request_id, token)

Takes a request_id and returns a %ElixirUber.Model.Request with request details.