| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plain-data polling protocol boundary. |
| 4 |
* |
| 5 |
* @package WCPOS\WooCommercePOS\Interfaces |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WCPOS\WooCommercePOS\Interfaces; |
| 9 |
|
| 10 |
/** |
| 11 |
* Wire protocols describe requests and responses; the lifecycle owns job state. |
| 12 |
*/ |
| 13 |
interface Poll_Provider_Adapter_Interface extends Provider_Adapter_Interface { |
| 14 |
/** |
| 15 |
* Parse the request phase and protocol hints. |
| 16 |
* |
| 17 |
* @param array $request Params, raw body, JSON, method and route. |
| 18 |
* @return array Phase (advertise/fetch/result), token and protocol hints. |
| 19 |
*/ |
| 20 |
public function parse( array $request ): array; |
| 21 |
|
| 22 |
/** |
| 23 |
* Build an offer, acknowledgement or not-found response. |
| 24 |
* |
| 25 |
* @param array $printer Printer and cached capabilities. |
| 26 |
* @param array $poll Parsed request, capability hint or not-found intent. |
| 27 |
* @param array|null $next_job Available job, or null for an idle/result response. |
| 28 |
* @return array{status:int, headers:array, body:string|array} |
| 29 |
*/ |
| 30 |
public function advertise( array $printer, array $poll, ?array $next_job ): array; |
| 31 |
|
| 32 |
/** |
| 33 |
* Negotiate before claiming the job. |
| 34 |
* |
| 35 |
* @param array $printer Printer and cached capabilities. |
| 36 |
* @param array $poll Parsed request. |
| 37 |
* @param array $job Candidate job, not yet claimed. |
| 38 |
* @return array Media type, or a response rejecting the request before claiming. |
| 39 |
*/ |
| 40 |
public function negotiate( array $printer, array $poll, array $job ): array; |
| 41 |
|
| 42 |
/** |
| 43 |
* Build the delivery response, even when rendering failed. |
| 44 |
* |
| 45 |
* @param array $job Claimed job. |
| 46 |
* @param array $render Rendered bytes (possibly empty) and peripheral controls. |
| 47 |
* @param array $poll Parsed request and negotiated media type. |
| 48 |
* @return array{status:int, headers:array, body:string|array} |
| 49 |
*/ |
| 50 |
public function deliver( array $job, array $render, array $poll ): array; |
| 51 |
|
| 52 |
/** |
| 53 |
* Identify the result target. |
| 54 |
* |
| 55 |
* @param array $poll Parsed result. |
| 56 |
* @return array{job_id:int|null} Null means active/unconfirmed claim lookup. |
| 57 |
*/ |
| 58 |
public function match_result( array $poll ): array; |
| 59 |
|
| 60 |
/** |
| 61 |
* Decode the printer result. |
| 62 |
* |
| 63 |
* @param array $poll Parsed result. |
| 64 |
* @return array{ok:bool, code:string, detail:string} |
| 65 |
*/ |
| 66 |
public function interpret_result( array $poll ): array; |
| 67 |
} |
| 68 |
|