Coder Social home page Coder Social logo

uber-php's Introduction

Uber PHP Client

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

A PHP client for authenticating with Uber using OAuth 2.0 and consuming the API.

This package is intended to be used for communicating with the Uber API after you've secured an access token from your users. To authenticate users and retrieve access tokens, use stevenmaguire/oauth2-uber.

Install

Via Composer

$ composer require stevenmaguire/uber-php

or update your composer.json file to include:

  "require": {
    "stevenmaguire/uber-php": "~1.0"
  }

Run composer update

Usage

Create client

$client = new Stevenmaguire\Uber\Client(array(
    'access_token' => 'YOUR ACCESS TOKEN',
    'server_token' => 'YOUR SERVER TOKEN',
    'use_sandbox'  => true, // optional, default false
    'version'      => 'v1', // optional, default 'v1'
    'locale'       => 'en_US', // optional, default 'en_US'
));

Please review the Sandbox documentation on how to develop and test against these endpoints without making real-world Requests and being charged.

Get Products

By location:

$products = $client->getProducts(array(
    'latitude' => '41.85582993',
    'longitude' => '-87.62730337'
));

By Id:

$product = $client->getProduct($product_id);

https://developer.uber.com/v1/endpoints/#product-types

Get Price Estimates

$estimates = $client->getPriceEstimates(array(
    'start_latitude' => '41.85582993',
    'start_longitude' => '-87.62730337',
    'end_latitude' => '41.87499492',
    'end_longitude' => '-87.67126465'
));

https://developer.uber.com/v1/endpoints/#price-estimates

Get Time Estimates

$estimates = $client->getTimeEstimates(array(
    'start_latitude' => '41.85582993',
    'start_longitude' => '-87.62730337'
));

https://developer.uber.com/v1/endpoints/#time-estimates

Get Promotions

$promotions = $client->getPromotions(array(
    'start_latitude' => '41.85582993',
    'start_longitude' => '-87.62730337',
    'end_latitude' => '41.87499492',
    'end_longitude' => '-87.67126465'
));

https://developer.uber.com/v1/endpoints/#promotions

Get User Activity

This feature is only available in version 1.1.

$client->setVersion('v1.1');
$history = $client->getHistory(array(
    'limit' => 50, // optional
    'offset' => 0 // optional
));

https://developer.uber.com/v1/endpoints/#user-activity-v1-1

Get User Profile

$profile = $client->getProfile();

https://developer.uber.com/v1/endpoints/#user-profile

Request A Ride

$request = $client->requestRide(array(
    'product_id' => '4bfc6c57-98c0-424f-a72e-c1e2a1d49939',
    'start_latitude' => '41.85582993',
    'start_longitude' => '-87.62730337',
    'end_latitude' => '41.87499492',
    'end_longitude' => '-87.67126465'
));

https://developer.uber.com/v1/endpoints/#request

Get Ride Details

$request = $client->getRequest($request_id);

https://developer.uber.com/v1/endpoints/#request-details

Get Ride Map

$map = $client->getRequestMap($request_id);

https://developer.uber.com/v1/endpoints/#request-map

Cancel Ride

$request = $client->cancelRequest($request_id);

https://developer.uber.com/v1/endpoints/#request-cancel

Rate Limiting

Rate limiting is implemented on the basis of a specific client's secret token. By default, 1,000 requests per hour can be made per secret token.

When consuming the service with this package, your rate limit status will be made available within the client.

$product = $client->getProduct($product_id);

$rate_limit = $client->getRateLimit();

$rate_limit->getLimit();        // Rate limit capacity per period
$rate_limit->getRemaining();    // Requests remaining in current period
$rate_limit->getReset();        // Timestamp in UTC time when the next period will begin

These values will update after each request. getRateLimit will return null after the client is created and before the first successful request.

https://developer.uber.com/v1/api-reference/#rate-limiting

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

uber-php's People

Contributors

guizmo51 avatar stevenmaguire avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.