定制 toktokdev/printapi-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

toktokdev/printapi-sdk

最新稳定版本:v1.0.0-beta

Composer 安装命令:

composer require toktokdev/printapi-sdk

包简介

Unofficial PHP SDK for PrintAPI

README 文档

README

Unofficial PHP SDK for PrintAPI built with Saloon v3.

Requirements

  • PHP 8.3 or higher
  • Composer

Installation

composer require toktokdev/printapi-sdk

Usage

Initialize the API client. Oauth2 authentication is handled automatically by the SDK using the client credentials flow:

use PrintAPI\PrintAPI;
  
// 1. Initialize the API client
$api = new PrintApi(
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
    testMode: true // Use test environment
);

// 2. Create an access token authenticator

$authenticator = $api->getAccessToken();

// 3. Authenticate the connector

$api->authenticate($authenticator);

See the official Saloon documentation for more information on the OAuth2 Client Credentials Grant.

API Implementation Status

Category Endpoint Status
Orders
POST /orders ✅ Implemented
GET /orders/{id} ✅ Implemented
GET /orders/{id}/status ✅ Implemented
GET /orders?offset={offset}&limit={limit} ✅ Implemented
GET /sync/statuses?since={since} ✅ Implemented
Checkout
POST /checkout/{code} 🚧 Planned
GET /checkout/{code} 🚧 Planned
POST /coupons/quote 🚧 Planned
Shipping
POST /shipping/quote ✅ Implemented
Uploads
POST /files/{code} 🚧 Planned
Products
GET /products?offset={offset}&limit={limit} ✅ Implemented
GET /products/{id} ✅ Implemented

Available Resources

Orders

// Place an order
$order = $api->orders()->create($orderData);

// Get a single order
$order = $api->orders()->get('order_id');

// Get order status
$status = $api->orders()->getStatus('order_id');

// List orders (with pagination)
$orders = $api->orders()->list();

// Get status updates since date
$updates = $api->orders()->getStatusUpdates($since);

Products

// List all products
$products = $api->products()->list();

// Get single product
$product = $api->products()->get('product_id');

Shipping

// Get shipping quote
$quote = $api->shipping()->getQuote($quoteRequest);

Development

# Install dependencies
composer install

# Run tests
composer test

# Run code style fixer
composer lint

# Run static analysis
composer phpstan

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

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