| 1 |
import { rpc } from "@web/core/network/rpc"; |
| 2 |
|
| 3 |
import { BasePrinter } from "@point_of_sale/app/utils/printer/base_printer"; |
| 4 |
|
| 5 |
/** |
| 6 |
* Printer that sends print requests thru /hw_proxy endpoints. |
| 7 |
* Doesn't require pos_iot to be installed. |
| 8 |
*/ |
| 9 |
export class HWPrinter extends BasePrinter { |
| 10 |
/** |
| 11 |
* @param {Object} params |
| 12 |
* @param {string} params.url full address of the iot box. E.g. `http://10.23.45.67:8069`. |
| 13 |
*/ |
| 14 |
setup(params) { |
| 15 |
super.setup(...arguments); |
| 16 |
this.url = params.url; |
| 17 |
} |
| 18 |
|
| 19 |
sendAction(data) { |
| 20 |
return rpc(`${this.url}/hw_proxy/default_printer_action`, { data }); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* @override |
| 25 |
*/ |
| 26 |
openCashbox() { |
| 27 |
return this.sendAction({ action: "cashbox" }); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* @override |
| 32 |
*/ |
| 33 |
sendPrintingJob(img) { |
| 34 |
return this.sendAction({ action: "print_receipt", receipt: img }); |
| 35 |
} |
| 36 |
} |