3.4 KiB
customergroup
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
customergroup.create
Source: src/store/customergroup/create.js
Creates a new customer group for the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
input |
object |
The customer group input. |
input.name |
string |
The customer group name (must not be a reserved name). |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, name: string, sort: number}> — The created customer group.
Throws
Error — If the name is empty or reserved.
Example
const group = await store.customergroup.create(42, { name: 'Wholesale' });
// => { id, name, sort }
customergroup.delete
Source: src/store/customergroup/delete.js
Deletes a customer group for the user's selected company by its id.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
id |
number |
The id of the customer group to delete. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<void>
Throws
Error — If the customer group is not found.
Example
await store.customergroup.delete(42, 5);
customergroup.list
Source: src/store/customergroup/list.js
Lists the customer groups 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, name: string, sort: number}>> — The customer groups.
Example
const groups = await store.customergroup.list(42);
// => [{ id, name, sort }]
customergroup.order
Source: src/store/customergroup/order.js
Reorders the customer groups of the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
input |
object |
The reorder input. |
input.customergroupIds |
Array<number> |
The customer group ids in their new order. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{customergroupIds: Array<number>}> — The applied order.
Throws
Error — If the order is invalid.
Example
const result = await store.customergroup.order(42, { customergroupIds: [3, 1, 2] });
// => { customergroupIds: [3, 1, 2] }
customergroup.update
Source: src/store/customergroup/update.js
Updates the name of a customer group for the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
id |
number |
The id of the customer group to update. |
input |
object |
The update input. |
input.name |
string |
The new customer group name. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, name: string, sort: number}> — The updated customer group.
Throws
Error — If the customer group is not found or the name is empty.
Example
const group = await store.customergroup.update(42, 5, { name: 'Retail' });
// => { id, name, sort }