risscsolutions / printformer-php-sdk
SDK for the printformer API
Installs: 4 746
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 12
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.4
- illuminate/config: ^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
- lcobucci/jwt: ^4.1
- symfony/http-foundation: ^6.0|^7.0
Requires (Dev)
- infection/infection: ^0.26.16
- jetbrains/phpstorm-attributes: ^1.0
- nyholm/nsa: ^1.3
- phpunit/phpunit: 9.6.8
- dev-master
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1
- dev-renovate/jetbrains-phpstorm-attributes-1.x-lockfile
- dev-renovate/phpunit-phpunit-11.x
- dev-renovate/infection-infection-0.x
- dev-renovate/phpunit-phpunit-9.x
- dev-renovate/guzzlehttp-guzzle-7.x-lockfile
- dev-renovate/font-awesome-6.x
- dev-renovate/lcobucci-jwt-5.x
- dev-renovate/font-awesome-5.x
- dev-renovate/actions-cache-4.x
- dev-renovate/actions-checkout-4.x
This package is auto-updated.
Last update: 2024-11-11 17:56:45 UTC
README
Documentation
Installation
composer require risscsolutions/printformer-php-sdk
Usage
Create a new Instance of the printformer-SDK
use Rissc\Printformer; $config = [ 'base_uri' => 'YOUR printformer URL', 'identifier' => 'YOUR TENANT IDENTIFIER', 'api_key' => 'YOUR TENANT API KEY', ]; $printformer = new Printformer($config);
Create a new User
$pfUser = $this->printformer->clientFactory()->user()->create([ 'first_name' => 'John', 'last_name' => 'Doe', 'locale' => 'en', 'email' => 'john.doe@rissc.com', ]);
Create a new Draft
by passing an array to the DraftClient
$draftClient = $printformer->clientFactory()->draft(); $draft = $draftClient ->create([ 'templateIdentifier' => 'YOUR MASTER TEMPLATE IDENTIFIER', 'user_identifier' => $pfUser->getIdentifier(), 'intent' => 'customize' ]);
or with a fluid builder
$draftBuilder = $printformer->builderFactory()->draft(); $draft = $draftBuilder ->template('YOUR MASTER TEMPLATE IDENTIFIER') ->user($pfUser->getIdentifier()) ->intent('customize') ->create();
Create a URL to the Editor
$url = (string)$printformer->urlGenerator()->editor() ->draft($draft->getIdentifier()) ->callback('https://YOUR-CALLBACK-URL-HERE') ->callbackCancel('https://YOUR-CANCEL-CALLBACK-URL-HERE') // Optional, if omitted the callback URL is used ->callbackHalt('https://YOUR-HALT-CALLBACK-URL-HERE') // Optional, if omitted the callbackCancel URL is used ->user($pfUser->getIdentifier()) ->step('preview') // Optional, if omitted the editor jumps to the last visited step
Create a Print PDF
$printformer->clientFactory()->processing()->create( [$draft->getIdentifier(), $otherDraft->getIdentifier()], 'https://YOUR-CALLBACK-URL-HERE' );
Create a URL to the Print PDF
(string)$printformer->urlGenerator() ->draftFiles() ->printFile($draft->getIdentifier()) ->expiresAt((new \DateTimeImmutable())->modify('+1 hour'))
Replicate a draft
$draftClient = $printformer->clientFactory()->draft(); $draft = $draftClient ->replicate($draft, []);