ubereats / php-sdk
PHP SDK for UberEats API
1.0.0
2025-02-02 23:42 UTC
Requires
- php: ^7.4 || ^8.0
- guzzlehttp/guzzle: ^7.4
- psr/log: ^1.1 || ^2.0 || ^3.0
- symfony/property-access: ^5.4 || ^6.0|| ^7.0
- symfony/serializer: ^5.4 || ^6.0|| ^7.0
- symfony/validator: ^5.4 || ^6.0|| ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.14
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.4 || ^6.0
README
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
- Getting Started
- Working with Orders
- Working with Stores
- Working with Deliveries
- Integration Features
Installation
composer require ubereats/php-sdk
Basic Usage
use UberEats\Client\UberEatsClient; // Create client instance $client = new UberEatsClient(); // 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
use UberEats\Webhook\WebhookHandler; $handler = new WebhookHandler(); $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: throw new \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
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- 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.