SudoSOS Back-end API / vouchers / VoucherGroupService
Class: VoucherGroupService ​
Constructors ​
Constructor ​
new VoucherGroupService(): VoucherGroupService;Returns ​
VoucherGroupService
Methods ​
asVoucherGroup() ​
static asVoucherGroup(bkgReq): VoucherGroup;Parameters ​
| Parameter | Type |
|---|---|
bkgReq | VoucherGroupParams |
Returns ​
asVoucherGroupParams() ​
static asVoucherGroupParams(req): VoucherGroupParams;Verifies whether the voucher group request translates to a valid object
Parameters ​
| Parameter | Type | Description |
|---|---|---|
req | VoucherGroupRequest | - |
Returns ​
The parameter object from the request
asVoucherGroupResponse() ​
static asVoucherGroupResponse(bkg, users): VoucherGroupResponse;Creates a voucher group from the request
Parameters ​
| Parameter | Type | Description |
|---|---|---|
bkg | VoucherGroup | voucher group |
users | User[] | users in the voucher group |
Returns ​
a voucher group response
createVoucherGroup() ​
static createVoucherGroup(bkgReq): Promise<{
users: User[];
voucherGroup: VoucherGroup;
}>;Saves a voucher group and its user relations to the database
Parameters ​
| Parameter | Type | Description |
|---|---|---|
bkgReq | VoucherGroupParams | voucher group parameters |
Returns ​
Promise<{ users: User[]; voucherGroup: VoucherGroup; }>
the saved voucher group and its users
createVoucherUsers() ​
static createVoucherUsers(
namePrefix,
active,
amount,
offset?): Promise<User[]>;Parameters ​
| Parameter | Type | Default value |
|---|---|---|
namePrefix | string | undefined |
active | Boolean | undefined |
amount | number | undefined |
offset | number | 0 |
Returns ​
Promise<User[]>
getVoucherGroups() ​
static getVoucherGroups(filters, params?): Promise<[VoucherGroup[], number]>;Returns all voucher groups with their users loaded
Parameters ​
| Parameter | Type | Description |
|---|---|---|
filters | VoucherGroupFilterParameters | - |
params | PaginationParameters | find options |
Returns ​
Promise<[VoucherGroup[], number]>
voucher groups with users and total count
updateBalance() ​
static updateBalance(
users,
balance,
isPositive?): Promise<Transfer[]>;Parameters ​
| Parameter | Type | Default value |
|---|---|---|
users | User[] | undefined |
balance | Dinero | undefined |
isPositive | boolean | true |
Returns ​
Promise<Transfer[]>
updateVoucherGroup() ​
static updateVoucherGroup(id, bkgReq): Promise<{
users: User[];
voucherGroup: VoucherGroup;
}>;Updates a voucher group and its user relations in the database
Parameters ​
| Parameter | Type | Description |
|---|---|---|
id | number | requested voucher group id |
bkgReq | VoucherGroupParams | new voucher group parameters |
Returns ​
Promise<{ users: User[]; voucherGroup: VoucherGroup; }>
updated voucher group with users, or undefined when not found
validateVoucherGroup() ​
static validateVoucherGroup(bkgReq): boolean;Verifies whether the voucher group request translates to a valid object
Parameters ​
| Parameter | Type | Description |
|---|---|---|
bkgReq | VoucherGroupParams | The voucher group request |
Returns ​
boolean
whether the voucher group is ok