Skip to content

nilsenj/uber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nilsenj/uber

uber api v1.* for Laravel 5.*

First go to uber dashboard

and get server_token

Installation

  1. Either run composer require nilsenj/uber or add "nilsenj/uber": "dev-master" to the require key in composer.json and run composer install

  2. Add \nilsenj\Uber\UberServiceProvider::class, to the providers key in config/app.php

  3. Add 'Uber' => \nilsenj\Uber\Facades\UberFacade::class, to the aliases key in config/app.php

  4. Do php artisan vendor:publish to publish the config. You can see it in config/uber.php

Usage

#####Using Contract

protected $uber;

    /**
     * UberController constructor.
     * @param UberContract $uber
     */
    public function __construct(UberContract $uber)
    {
        $this->uber = $uber;
    }
    
    public function index() {
        $this->uber->someMethod();
    }
    

#####List Of Methods

Get Products

By location:

$products = app('UberContract')->getProductsByLocation($latitude, $longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/products-get

By Id:

$product = app('UberContract')->getProductsById($productId);

https://developer.uber.com/docs/riders/references/api/v1.2/products-product_id-get

Get Price Estimates

$estimates = app('UberContract')->getPriceEstimates($start_latitude, $start_longitude, $end_latitude, $end_longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/estimates-price-get

Get Time Estimates

$estimates = app('UberContract')->getTimeEstimates($start_latitude, $start_longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/estimates-time-get

Get Promotions

$promotions = app('UberContract')->getPromotions($start_latitude, $start_longitude, $end_latitude, $end_longitude);

https://developer.uber.com/docs/riders/ride-promotions/introduction

Get User Activity

This feature is only available since version 1.1.

$history = app('UberContract')->getUserActivity();

https://developer.uber.com/docs/riders/references/api/v1.2/history-get

Get User Profile

$profile = app('UberContract')->getUserProfile();

https://developer.uber.com/docs/riders/references/api/v1.2/me-get

Update User Profile

$attributes = array('applied_promotion_codes' => 'PROMO_CODE');
$profileResponse = app('UberContract')->updateUserProfile($attributes);

https://developer.uber.com/docs/riders/references/api/v1.2/me-patch

Get Payment Methods

$paymentMethods = app('UberContract')->getPaymentMethods();

https://developer.uber.com/docs/riders/references/api/v1.2/payment-methods-get

Get Place

$placeId = 'home';
$place = app('UberContract')->getPlace($placeId);

https://developer.uber.com/docs/riders/references/api/v1.2/places-place_id-get

Update a Place

$placeId = 'home';
$attributes = array('address' => '685 Market St, San Francisco, CA 94103, USA');
$place = app('UberContract')->updatePlace($placeId, $attributes);

https://developer.uber.com/docs/riders/references/api/v1.2/places-place_id-put

Request A Ride

$request = app('UberContract')->requestToRide($start_latitude, $start_longitude, $end_latitude, 
                $end_longitude, $product_id = null, $surge_confirmation_id = null, $payment_method_id = null);

https://developer.uber.com/docs/riders/ride-requests/tutorials/api/best-practices#handling-surge-pricing

Get Current Ride Details

$request = app('UberContract')->getCurrentRideDetails();

https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-get

Get Ride Details

$request = app('UberContract')->getRideDetails($requestId);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-get

Update Current Ride Details

$end_address= '685 Market St, San Francisco, CA 94103, USA',
$end_nickname = 'da crib',
$end_place_id = 'home',
$end_latitude = '41.87499492',
$end_longitude = '-87.67126465'

$updateRequest = app('UberContract')->updateCurrentRideDetails($end_address, $end_nickname, $end_place_id,
                                                                    $end_latitude, $end_longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-patch

Update Ride Details

$requestId = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939'

$end_address = '685 Market St, San Francisco, CA 94103, USA',
$end_nickname = 'da crib',
$end_place_id = 'home',
$end_latitude = '41.87499492',
$end_longitude = '-87.67126465'

$updateRequest = Uber::updateRideDetails($requestId, $end_address, $end_nickname, $end_place_id,
                                                             $end_latitude, $end_longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-patch

Get Ride Estimate

$product_id = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939',
$start_latitude = '41.85582993',
$start_longitude = '-87.62730337',
$end_latitude = '41.87499492', // optional
$end_longitude = '-87.67126465', // optional

$requestEstimate = app('UberContract')->getRideEstimate($product_id, $start_latitude, 
                    $start_longitude, $end_latitude, $end_longitude);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-estimate-post

Get Ride Map

$map = Uber::getRideMap($requestId);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-map-get

Get Ride Receipt

$receipt = app('UberContract')->getRideReceipt($requestId);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-delete

Cancel Ride

$request = app('UberContract')->cancelRide($requestId);

https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-delete

Create Reminder

$attributes = array(
    'reminder_time' => '1429294463',
    'phone_number' => '555-555-5555',
    'event' => array(
        'time' => '1429294463',
        'name' => 'Frisbee with friends',
        'location' => 'Dolores Park',
        'latitude' => '37.759773',
        'longitude' => '-122.427063',
    ),
    'product_id' => 'a1111c8c-c720-46c3-8534-2fcdd730040d',
    'trip_branding' => array(
        'link_text' => 'View team roster',
        'partner_deeplink' => 'partner://team/9383',
    )
);
$reminder = app('UberContract')->createReminder($attributes)

https://developer.uber.com/docs/riders/references/api/v1.2/reminders-post

Get Reminder

$reminderId = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939';
$reminder = app('UberContract')->getReminder($reminderId);

https://developer.uber.com/docs/riders/references/api/v1.2/reminders-reminder_id-get

Update Reminder

$reminderId = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939';
$attributes = array(
    'reminder_time' => '1429294463',
    'phone_number' => '555-555-5555',
    'event' => array(
        'time' => '1429294463',
        'name' => 'Frisbee with friends',
        'location' => 'Dolores Park',
        'latitude' => '37.759773',
        'longitude' => '-122.427063',
    ),
    'product_id' => 'a1111c8c-c720-46c3-8534-2fcdd730040d',
    'trip_branding' => array(
        'link_text' => 'View team roster',
        'partner_deeplink' => 'partner://team/9383',
    )
);
$reminder = Uber::updateReminder($reminderId, $attributes);

https://developer.uber.com/docs/riders/references/api/v1.2/reminders-reminder_id-patch

Cancel Reminder

$reminderId = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939';
$reminder = app('UberContract')->cancelReminder($reminderId);

https://developer.uber.com/docs/riders/references/api/v1.2/reminders-reminder_id-delete

Rate Limiting

This feature is only supported for v1 version of the API.

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.

$rateLimit = app('UberContract')->rateLimiting($productId);
will return an array
["limit" => , "remaining" => , "reset" => ]

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

Using the Sandbox

Modify the status of an ongoing sandbox Request.

These methods will throw Stevenmaguire\Uber\Exception when invoked while the client is not in sandbox mode. The underlying API endpoints have no effect unless you are using the sandbox environment.

$product_id = '4bfc6c57-98c0-424f-a72e-c1e2a1d49939',
$start_latitude = '41.85582993',
$start_longitude = '-87.62730337',
$end_latitude = '41.87499492',
$end_longitude = '-87.67126465'

$updateRequest = app('UberContract')->modifyOngoingStatusRequestSandbox(
                 $product_id, $start_latitude, $start_longitude, $end_latitude,
                 $end_longitude, $status = ''); 

About

uber api v1 package for laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages