Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kduma authored Dec 15, 2022
1 parent f155859 commit e7b875e
Showing 1 changed file with 1 addition and 142 deletions.
143 changes: 1 addition & 142 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,148 +17,7 @@ composer require kduma/webprint-client

## Usage

Available Methods:

```php
//Create Api Client Instance
$api = new \KDuma\WebPrintClient\WebPrintApi(
new \KDuma\WebPrintClient\HttpClient\GuzzleHttp7Client(
endpoint: 'https://print.server.local/api/web-print',
key: 'API_KEY'
)
);

// Get List of all available printers
$printers = $api->GetPrinters();

// Get List of all printers capable processing ZPL language
$printers = $api->GetPrinters(type_filter: 'zpl');

// Get Printer Details
$printer = $api->GetPrinter(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Get List of recently submitted Promises
$promises = $api->GetPromises(
page: 1,
total_pages: &$total_pages // passed by reference
);

// Get Promise Details
$promise = $api->GetPromise(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Create Promise
$promise = $api->CreatePromise(
name: 'Print Job',
type: 'zpl',
meta: ['format' => '4x6"']
);

// Create and Immediately print Promise
$promise = $api->CreatePromiseAndPrint(
name: 'Print Job',
type: 'zpl',
printer_uuid: '00000000-0000-0000-0000-000000000000',
file_name: 'label.zpl',
content: '^XA...'
);

// Get Promise Details
$promise = $api->GetPromise(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Update Promise
$api->UpdatePromise(
uuid: '00000000-0000-0000-0000-000000000000',
name: 'Updated',
printer_uuid: '00000000-0000-0000-0000-000000000000',
meta: ['dupa' => 123],
ppd_options: [],
status: 'ready'
);

// Delete Promise
$api->DeletePromise(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Get Promise Content
$content = $api->GetPromiseContent(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Upload Promise Content
$api->SetPromiseContent(
uuid: '00000000-0000-0000-0000-000000000000',
content: fopen('myfile.txt', 'r'),
file_name: 'myfile.txt'
);

// Send Promise to Print Queue
$api->PrintPromise(
uuid: '00000000-0000-0000-0000-000000000000'
);

// Create Print Dialog
$dialog = $api->CreateDialog(
uuid: '00000000-0000-0000-0000-000000000000',
auto_print: true,
redirect_url: 'http://example.com/',
restricted_ip: '127.0.0.1'
);

// Get Print Dialog
$dialog = $api->GetDialog(
uuid: '00000000-0000-0000-0000-000000000000'
);
```

Sample: Use create print Promise and redirect user to print Dialog; Content upload after response termination
```php
public function PrintDocument()
{
$api = new \KDuma\WebPrintClient\WebPrintApi(
new \KDuma\WebPrintClient\HttpClient\GuzzleHttp7Client(
endpoint: 'https://print.server.local/api/web-print',
key: 'API_KEY'
)
);

// Create Promise
$promise = $api->CreatePromise(
name: 'Test Document',
type: 'ppd',
meta: [
'pages' => '2',
'date' => '2021-09-12'
]
);

// Create Print Dialog
$dialog = $api->CreateDialog(
uuid: $promise,
auto_print: true,
redirect_url: 'http://example.com/return-url',
);

App::terminating(function () use ($promise, $api) {
$pdf = PDF::loadView('documents.test');

// Upload Promise Content
$api->SetPromiseContent(
uuid: $promise,
content: $pdf->output(),
file_name: 'test.pdf'
);
});

return redirect($dialog->getLink());
}
```
Check documentation here: https://opensource.duma.sh/libraries/webprint-client

### Testing

Expand Down

0 comments on commit e7b875e

Please sign in to comment.