composer require risscsolutions/printformer-php-sdk
use Rissc\Printformer;
$config = [
'base_uri' => 'YOUR printformer URL',
'identifier' => 'YOUR TENANT IDENTIFIER',
'api_key' => 'YOUR TENANT API KEY',
];
$printformer = new Printformer($config);
$pfUser = $this->printformer->clientFactory()->user()->create([
'first_name' => 'John',
'last_name' => 'Doe',
'locale' => 'en',
'email' => '[email protected]',
]);
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();
$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
$printformer->clientFactory()->processing()->create(
[$draft->getIdentifier(), $otherDraft->getIdentifier()],
'https://YOUR-CALLBACK-URL-HERE'
);
(string)$printformer->urlGenerator()
->draftFiles()
->printFile($draft->getIdentifier())
->expiresAt((new \DateTimeImmutable())->modify('+1 hour'))
$draftClient = $printformer->clientFactory()->draft();
$draft = $draftClient
->replicate($draft, []);