designerkarten / dwk-api-v1-printjobs-client-php
PHP client for the DWK Printjobs API
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/designerkarten/dwk-api-v1-printjobs-client-php
Requires
- php: >=8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- phpstan/phpstan: ^2.1
This package is not auto-updated.
Last update: 2025-12-31 16:01:35 UTC
README
This PHP client makes it easy for you as a print partner to access our API. It allows you to a) submit status updates, b) view the status history of a job being produced at your end, and c) retrieve all object data relevant for handling our print jobs – thereby creating a clear, efficient interface for collaboration.
Here’s how easy it is to confirm the acceptance of a print order:
$response = $client->confirm(
8932, // Our Job ID
348763328, // Your Job ID
119.00 // Your Price
);
Table of Contents
- Requirements
- Installation
- Setup (.env)
- Quickstart
- Client Methods
- Examples
- Response Envelope
- Error Handling
- Security Notes
- License
Requirements
- PHP >= 8.1
- Composer
- Guzzle (installed as a dependency)
- Access to the DWK API (Base URL & Bearer Token)
Installation
As a library:
composer require designerkarten/dwk-api-v1-printjobs-client-php
Autoloading via PSR-4:
- Namespace root:
Designerkarten\DWK\Api\PrintjobsClient - Main class:
Designerkarten\DWK\Api\PrintjobsClient\PrintjobsClient
Setup .env
If you want to use environment variables, create a .env file (based on .env.example):
API_URI= API_TOKEN= # Just for testing PRINTJOB_TEST_ID= PRINTJOB_TEST_YOUR_JOB_ID=
Meaning:
API_URI– Base URL of the APIAPI_TOKEN– Bearer token for authenticationPRINTJOB_TEST_ID– Example print job ID for tests/examplesPRINTJOB_TEST_YOUR_JOB_ID– Examplejob_idfor status 100
Quickstart
<?php require __DIR__ . '/vendor/autoload.php'; use Designerkarten\DWK\Api\PrintjobsClient\PrintjobsClient; use Designerkarten\DWK\Api\PrintjobsClient\Exception\ApiException; $dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__)); $dotenv->load(); // Create client (SSL validation controllable via env) $client = new PrintjobsClient( env('API_URI'), env('API_TOKEN') ); // Getting object map as array $map = $client->getObjectMap()->toArray();
Client Methods
getObjectMap(): PrintjobsResponse // GET /info/printjobs/objectmap getHistory(int $id): PrintjobsResponse // GET /printjobs/{id}/state/history updateStatus(int $id, int $status, array $extra = []): PrintjobsResponse // PATCH /printjobs/{id}/state // Easy status updates: confirm(int $id, string $jobId, float $price): PrintjobsResponse // status 1 reject(int $id, string $message, float $price): PrintjobsResponse // status 2 reportException(int $id, string $message): PrintjobsResponse // status 10 cancellationConfirm(int $id): PrintjobsResponse // status 91 productionStarted(int $id): PrintjobsResponse // status 200 furtherProcessingStarted(int $id): PrintjobsResponse // status 300 shippingPreparationStarted(int $id): PrintjobsResponse // status 400 shippingLabelCreated(int $id, string $trackingId): PrintjobsResponse // status 500 shipped(int $id): PrintjobsResponse // status 600
Examples
Confirm order
$resp = $client->confirm( id: env('PRINTJOB_TEST_ID'), jobId: env('PRINTJOB_TEST_YOUR_JOB_ID'), price: 12.50 );
Reject order
$resp = $client->reject( id: env('PRINTJOB_TEST_ID'), message: 'A valid reason' );
Report error
$resp = $client->reportException( id: env('PRINTJOB_TEST_ID'), message: 'Bleed incorrect' );
Confirm cancellation
$resp = $client->cancellationConfirm( id: env('PRINTJOB_TEST_ID') );
Shipping label created
$resp = $client->shippingLabelCreated( id: env('PRINTJOB_TEST_ID'), trackingId: '00340434161234567890' );
Retrieve history
$history = $client->getHistory(env('PRINTJOB_TEST_ID'));
Response Envelope
Success
{
"success": {
"message": "Status updated successfully",
"data": { "status": "600" }
}
}
Error
{
"error": {
"message": "'tracking_id' field is required"
}
}
Error Handling
$response = $client->shipped(30920942); $response->toJson(); // {"error":{"message":"Printjob 30920942 does not exist","data":[]}}
Security Notes
- Token only via
Authorization: Bearer <TOKEN>. - Never commit
.env; only version.env.example.
License
MIT