A receipt printer's poll (Epson Server Direct Print)
const url = 'https://api.aerandil.com/v1/print/epson/sdp?tenant=2489E9AD-2EE2-8E00-8EC9-32D5F69181C0';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams({ ConnectionType: 'GetRequest', ID: 'example', Name: 'example', Password: 'example', ResponseFile: 'example' })};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url 'https://api.aerandil.com/v1/print/epson/sdp?tenant=2489E9AD-2EE2-8E00-8EC9-32D5F69181C0' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data ConnectionType=GetRequest \ --data ID=example \ --data Name=example \ --data Password=example \ --data ResponseFile=exampleWhere a printer configured for Epson Server Direct Print comes for its work. The printer POSTs a form (application/x-www-form-urlencoded): ConnectionType=GetRequest asks for the next job and is answered 200 text/xml with <PrintRequestInfo Version="2.00"> — one <ePOSPrint> with <Parameter> (devid, timeout, printjobid) and <PrintData> (the receipt’s <epos-print>) — or an empty 200 when nothing is queued; ConnectionType=SetResponse reports the jobs’ results in ResponseFile (<PrintResponseInfo>) and is answered an empty 200. Public: a printer carries no bearer. The printer names its tenant (tenant query parameter), its device by ID (the device’s code) and proves it with the secret whose SHA-256 the device holds (print_secret_hash), as the HTTP Basic password or a Password form field. Refusals carry no body: 401 (not an active printer holding that secret; with a Basic challenge), 429 (more than a burst of 5 polls, refilled at one a second), 404 (AERANDIL_PRINT_SDP_ENABLED is off).
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”The tenant the printer is registered under (not a secret).
Request Bodyrequired
Section titled “Request Bodyrequired”object
The printer’s Server Direct Print ID: its device code.
The printer’s secret, when not sent as HTTP Basic.
SetResponse only: the <PrintResponseInfo> document.
Responses
Section titled “Responses”A job as <PrintRequestInfo>, or an empty body.
Not an active printer holding that secret (no body).
Server Direct Print is not enabled (no body).
Polling faster than a printer is set to (no body).