ubereats/php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ubereats/php-sdk

最新稳定版本:1.0.0

Composer 安装命令:

composer require ubereats/php-sdk

包简介

PHP SDK for UberEats API

README 文档

README

Latest Version on Packagist Total Downloads License CI PHP Version Build Status Code Coverage PHPStan PHP CS Fixer Support 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

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

  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.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-02