ubereats/php-sdk
最新稳定版本:1.0.0
Composer 安装命令:
composer require ubereats/php-sdk
包简介
PHP SDK for UberEats API
README 文档
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): OrderacceptOrder(string $orderId, AcceptOrderRequest $request): OrderdenyOrder(string $orderId, DenyOrderRequest $request): OrdercancelOrder(string $orderId, CancelOrderRequest $request): Order
Stores
getStore(string $storeId): StoregetStores(): 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.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-02