Skip to content

SudoSOS Back-end API / vouchers / VoucherGroupService

Class: VoucherGroupService ​

Constructors ​

Constructor ​

ts
new VoucherGroupService(): VoucherGroupService;

Returns ​

VoucherGroupService

Methods ​

asVoucherGroup() ​

ts
static asVoucherGroup(bkgReq): VoucherGroup;

Parameters ​

ParameterType
bkgReqVoucherGroupParams

Returns ​

VoucherGroup


asVoucherGroupParams() ​

ts
static asVoucherGroupParams(req): VoucherGroupParams;

Verifies whether the voucher group request translates to a valid object

Parameters ​

ParameterTypeDescription
reqVoucherGroupRequest-

Returns ​

VoucherGroupParams

The parameter object from the request


asVoucherGroupResponse() ​

ts
static asVoucherGroupResponse(bkg, users): VoucherGroupResponse;

Creates a voucher group from the request

Parameters ​

ParameterTypeDescription
bkgVoucherGroupvoucher group
usersUser[]users in the voucher group

Returns ​

VoucherGroupResponse

a voucher group response


createVoucherGroup() ​

ts
static createVoucherGroup(bkgReq): Promise<{
  users: User[];
  voucherGroup: VoucherGroup;
}>;

Saves a voucher group and its user relations to the database

Parameters ​

ParameterTypeDescription
bkgReqVoucherGroupParamsvoucher group parameters

Returns ​

Promise<{ users: User[]; voucherGroup: VoucherGroup; }>

the saved voucher group and its users


createVoucherUsers() ​

ts
static createVoucherUsers(
   namePrefix, 
   active, 
   amount, 
offset?): Promise<User[]>;

Parameters ​

ParameterTypeDefault value
namePrefixstringundefined
activeBooleanundefined
amountnumberundefined
offsetnumber0

Returns ​

Promise<User[]>


getVoucherGroups() ​

ts
static getVoucherGroups(filters, params?): Promise<[VoucherGroup[], number]>;

Returns all voucher groups with their users loaded

Parameters ​

ParameterTypeDescription
filtersVoucherGroupFilterParameters-
paramsPaginationParametersfind options

Returns ​

Promise<[VoucherGroup[], number]>

voucher groups with users and total count


updateBalance() ​

ts
static updateBalance(
   users, 
   balance, 
isPositive?): Promise<Transfer[]>;

Parameters ​

ParameterTypeDefault value
usersUser[]undefined
balanceDineroundefined
isPositivebooleantrue

Returns ​

Promise<Transfer[]>


updateVoucherGroup() ​

ts
static updateVoucherGroup(id, bkgReq): Promise<{
  users: User[];
  voucherGroup: VoucherGroup;
}>;

Updates a voucher group and its user relations in the database

Parameters ​

ParameterTypeDescription
idnumberrequested voucher group id
bkgReqVoucherGroupParamsnew voucher group parameters

Returns ​

Promise<{ users: User[]; voucherGroup: VoucherGroup; }>

updated voucher group with users, or undefined when not found


validateVoucherGroup() ​

ts
static validateVoucherGroup(bkgReq): boolean;

Verifies whether the voucher group request translates to a valid object

Parameters ​

ParameterTypeDescription
bkgReqVoucherGroupParamsThe voucher group request

Returns ​

boolean

whether the voucher group is ok