承接 ready2order/r2o-api-client-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ready2order/r2o-api-client-php

Composer 安装命令:

composer require ready2order/r2o-api-client-php

包简介

PHP library for ready2order POS API v1

README 文档

README

PHP client library for the ready2order POS API v1. Wraps the REST API at api.ready2order.com.

Getting Started

  1. Register as a developer at api.ready2order.com to obtain your "Developer Token"
  2. Use the developer token to request access to existing accounts and obtain an "Account Token"
  3. Use the "Account Token" for your API requests

For full API documentation, see ready2order.com/api/doc.

Installation

Install via Composer:

composer require ready2order/r2o-api-client-php

Basic Usage

use ready2order\Client;

$client = new Client('your-account-token');

// Fetch account information
$company = $client->get('company');
print_r($company);

HTTP Methods

The client supports all standard HTTP methods:

// GET - Retrieve resources
$products = $client->get('products');
$product = $client->get('products/123');

// POST - Create resources
$newProduct = $client->post('products', [
    'product_name' => 'Coffee',
    'product_price' => '3.50',
]);

// PUT - Create or replace resources
$productGroup = $client->put('productgroups', [
    'productgroup_name' => 'Beverages',
]);

// PATCH - Update resources
$updated = $client->patch('products/123', [
    'product_price' => '4.00',
]);

// DELETE - Remove resources
$client->delete('products/123');

Configuration Options

Custom Timeout

Set a custom timeout for all requests (default: 10 seconds):

$client = new Client('your-token');
$client->setTimeout(30); // 30 seconds

// Or override per request (last parameter)
$result = $client->get('products', [], 60); // 60 second timeout

Language Header

Set the Accept-Language header for localized responses:

$client = new Client('your-token');
$client->setLanguage('de-DE'); // German
$client->setLanguage('en-US'); // English (default)

Custom API Endpoint

For testing or custom deployments, pass the endpoint as the second constructor parameter:

$client = new Client('your-token', 'https://custom-api.example.com/v1');

Error Handling

The client throws specific exceptions for different error scenarios:

use ready2order\Client;
use ready2order\Exceptions\ErrorResponseException;
use ready2order\Exceptions\ResourceNotFoundException;
use ready2order\Exceptions\InvalidResponseException;

$client = new Client('your-token');

try {
    $product = $client->get('products/999999');
} catch (ResourceNotFoundException $e) {
    // HTTP 404 - Resource not found
    echo "Product not found: " . $e->getMessage();
} catch (ErrorResponseException $e) {
    // API returned an error (4xx/5xx)
    echo "API error: " . $e->getMessage();

    // Access full error response data
    $errorData = $e->getData();
    if ($errorData) {
        print_r($errorData);
    }
} catch (InvalidResponseException $e) {
    // Response could not be JSON-decoded
    echo "Invalid response from API";
}

Pagination

List endpoints support pagination via query parameters:

$client = new Client('your-token');

// Fetch first page of products (default limit varies by endpoint)
$page1 = $client->get('products', [
    'page' => 1,
    'limit' => 50,
]);

// Fetch next page
$page2 = $client->get('products', [
    'page' => 2,
    'limit' => 50,
]);

Complete Example

use ready2order\Client;
use ready2order\Exceptions\ErrorResponseException;

$client = new Client('your-token');

// Create a product group
$productGroup = $client->put('productgroups', [
    'productgroup_name' => 'Soft drinks',
]);

// Create a product in that group
$product = $client->put('products', [
    'product_name' => 'Cola',
    'product_price' => '2.50',
    'product_vat' => '20',
    'productgroup' => [
        'productgroup_id' => $productGroup['productgroup_id'],
    ],
]);

echo "Created product: " . $product['product_name'];

Requirements

  • PHP 7.4 or higher
  • ext-curl
  • ext-json
  • guzzlehttp/guzzle ^7.0

License

MIT

ready2order/r2o-api-client-php 适用场景与选型建议

ready2order/r2o-api-client-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.32k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2020 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ready2order/r2o-api-client-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ready2order/r2o-api-client-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 ready2order/r2o-api-client-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-21