Skip to content

Repository files navigation

UberEats PHP SDK

Latest Version on PackagistTotal DownloadsLicenseCIPHP VersionBuild StatusCode CoveragePHPStanPHP CS FixerSupport Palestine

A modern PHP SDK for the UberEats API, supporting PHP 7.4 and above.

Features

  • 🚀 Modern PHP 7.4+ with strict typing
  • 🔒 Type-safe request/response objects
  • 🧪 Comprehensive test coverage
  • 📝 Detailed documentation
  • 🔄 Webhook support
  • 🛠️ PSR-3 logging support
  • 🎯 PSR-12 coding standards
  • 🔍 Static analysis with PHPStan level max

Requirements

  • PHP 7.4 or higher
  • Composer
  • Guzzle HTTP Client
  • PSR-3 Logger (optional)

Documentation

Installation

composer require ubereats/php-sdk

Basic Usage

useUberEats\Client\UberEatsClient;
// Create client instance$client = newUberEatsClient();
// Authenticate$token = $client->authenticate(
clientId: 'your-client-id',
clientSecret: 'your-client-secret'
);
// Get order details$order = $client->getOrder('order-id');
// Get store details$store = $client->getStore('store-id');

Available Methods

Authentication

  • authenticate(string $clientId, string $clientSecret): AccessToken

Orders

  • getOrder(string $orderId): Order
  • acceptOrder(string $orderId, AcceptOrderRequest $request): Order
  • denyOrder(string $orderId, DenyOrderRequest $request): Order
  • cancelOrder(string $orderId, CancelOrderRequest $request): Order

Stores

  • getStore(string $storeId): Store
  • getStores(): StoreCollection

Webhook Handling

useUberEats\Webhook\WebhookHandler;
$handler = newWebhookHandler();
$event = $handler->handle($payload);
switch ($event->type) {
case'orders.notification':
handleOrderNotification($event);
break;
case'orders.scheduled.notification':
handleScheduledOrder($event);
break;
case'delivery.state_changed':
handleDeliveryStateChange($event);
break;
default:
thrownew \InvalidArgumentException('Unknown event type');
}

Error Handling

The SDK throws UberEatsException for any API errors. Each exception includes:

  • HTTP status code
  • Error message
  • Original response data
try {
$order = $client->getOrder('invalid-id');
} catch (UberEatsException$e) {
echo$e->getMessage();
echo$e->getCode();
}

Development

Testing

composer test

Static Analysis

composer phpstan

Code Style

composer cs-fix

Code Coverage

composer test-coverage

Security

If you discover any security related issues, please email contact@benmacha.tn instead of using the issue tracker.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

Credits

License

This package is licensed under the MIT License. See the LICENSE file for details.

About

A modern PHP SDK for the UberEats API, supporting PHP 7.4 and above.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages