toktokdev/printapi-sdk

Unofficial PHP SDK for PrintAPI

v1.0.0-beta 2025-04-02 17:07 UTC

This package is auto-updated.

Last update: 2025-04-02 17:13:05 UTC


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.