3.8 KiB
printeragent
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
printeragent.create
Source: src/store/printeragent/create.js
Creates an unpaired printer agent for the user's selected company. The agent registers itself later using the pairing pin.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
input |
object |
The printer agent input. |
input.name |
string |
The display name. |
input.pairingpin |
string |
The pairing pin the agent uses to register. |
[input.sort] |
number |
Display order (integer, ascending). Default 0. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}> — The created printer agent.
Throws
Error — 'Invalid printeragent' if name or pairingpin is missing/blank or sort is not an integer.
Example
const agent = await store.printeragent.create(42, { name: 'Bar printer', pairingpin: '123456' });
printeragent.delete
Source: src/store/printeragent/delete.js
Deletes a printer agent of the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
id |
number |
The printer agent id. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<void>
Throws
Error — 'Printeragent not found' if the id is unknown in the company.
Example
await store.printeragent.delete(42, 5);
printeragent.list
Source: src/store/printeragent/list.js
Lists the printer agents of the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<Array<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}>> — The printer agents.
Example
const agents = await store.printeragent.list(42);
// => [{ id, companyId, name, token, pairingpin, pairedAt, clientserial, clientmodel, clientstate, agentversion, lastseenAt, updatedAt, sort }]
printeragent.update
Source: src/store/printeragent/update.js
Updates name and/or sort of a printer agent of the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
input |
object |
The update input. |
input.id |
number |
The printer agent id. |
[input.name] |
string |
The new display name. |
[input.sort] |
number |
The new display order (integer). |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}> — The updated printer agent.
Throws
Error — 'Invalid printeragent' if name is blank, sort is not an integer, or neither is given; 'Printeragent not found' if id is unknown in the company.
Example
const agent = await store.printeragent.update(42, { id: 5, name: 'Kitchen printer', sort: 1 });