uber api v1. for Laravel 5.
First go to uber dashboard
and get server_token
Either run composer require nilsenj/uber
or add "nilsenj/uber": "dev-master"
to the require
key in composer.json
and run composer install
Add \nilsenj\Uber\UberServiceProvider::class,
to the providers
key in config/app.php
Add 'Uber' => \nilsenj\Uber\Facades\UberFacade::class,
to the aliases
key in config/app.php
Do php artisan vendor:publish
to publish the config. You can see it in config/uber.php
protected $uber;
/**
* UberController constructor.
* @param UberContract $uber
*/
public function __construct(UberContract $uber)
{
$this->uber = $uber;
}
public function index() {
$this->uber->someMethod();
}
$products = app('UberContract')->getProductsByLocation($latitude, $longitude);
https://developer.uber.com/docs/riders/references/api/v1.2/products-get
$product = app('UberContract')->getProductsById($productId);
https://developer.uber.com/docs/riders/references/api/v1.2/products-product_id-get
$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
$estimates = app('UberContract')->getTimeEstimates($start_latitude, $start_longitude);
https://developer.uber.com/docs/riders/references/api/v1.2/estimates-time-get
$promotions = app('UberContract')->getPromotions($start_latitude, $start_longitude, $end_latitude, $end_longitude);
https://developer.uber.com/docs/riders/ride-promotions/introduction
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
$profile = app('UberContract')->getUserProfile();
https://developer.uber.com/docs/riders/references/api/v1.2/me-get
$attributes = array('applied_promotion_codes' => 'PROMO_CODE');
$profileResponse = app('UberContract')->updateUserProfile($attributes);
https://developer.uber.com/docs/riders/references/api/v1.2/me-patch
$paymentMethods = app('UberContract')->getPaymentMethods();
https://developer.uber.com/docs/riders/references/api/v1.2/payment-methods-get
$placeId = 'home';
$place = app('UberContract')->getPlace($placeId);
https://developer.uber.com/docs/riders/references/api/v1.2/places-place_id-get
$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 = app('UberContract')->requestToRide($start_latitude, $start_longitude, $end_latitude,
$end_longitude, $product_id = null, $surge_confirmation_id = null, $payment_method_id = null);
$request = app('UberContract')->getCurrentRideDetails();
https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-get
$request = app('UberContract')->getRideDetails($requestId);
https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-get
$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
$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
$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
$map = Uber::getRideMap($requestId);
https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-map-get
$receipt = app('UberContract')->getRideReceipt($requestId);
https://developer.uber.com/docs/riders/references/api/v1.2/requests-current-delete
$request = app('UberContract')->cancelRide($requestId);
https://developer.uber.com/docs/riders/references/api/v1.2/requests-request_id-delete
$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
$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
$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
$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
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
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 = '');