Compare commits

..

No commits in common. "d837654617f7de5d055ffb06c65e2cd52f65c604" and "71e3d0efe2cbde47aea0f26cb5a8b5cd3312707d" have entirely different histories.

4 changed files with 7 additions and 58 deletions

View File

@ -35,5 +35,4 @@ export enum ResponseObjectType {
USER = 'USER', USER = 'USER',
USERGROUP = 'USERGROUP', USERGROUP = 'USERGROUP',
USERPERMISSIONS = 'USERPERMISSIONS', USERPERMISSIONS = 'USERPERMISSIONS',
SELFSERVICEDONOR = 'SELFSERVICEDONOR'
} }

View File

@ -2,7 +2,6 @@ import { IsInt, IsNotEmpty, IsPositive } from 'class-validator';
import { DistanceDonation } from '../entities/DistanceDonation'; import { DistanceDonation } from '../entities/DistanceDonation';
import { ResponseObjectType } from '../enums/ResponseObjectType'; import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse'; import { IResponse } from './IResponse';
import { ResponseSelfServiceDonor } from './ResponseSelfServiceDonor';
/** /**
* Defines the runner selfservice donation response. * Defines the runner selfservice donation response.
@ -19,7 +18,7 @@ export class ResponseSelfServiceDonation implements IResponse {
* The donation's donor. * The donation's donor.
*/ */
@IsNotEmpty() @IsNotEmpty()
donor: ResponseSelfServiceDonor; donor: string;
/** /**
* The donation's amount in the smalles unit of your currency (default: euro cent). * The donation's amount in the smalles unit of your currency (default: euro cent).
@ -36,7 +35,9 @@ export class ResponseSelfServiceDonation implements IResponse {
amountPerDistance: number; amountPerDistance: number;
public constructor(donation: DistanceDonation) { public constructor(donation: DistanceDonation) {
this.donor = new ResponseSelfServiceDonor(donation.donor); if (!donation.donor.middlename) { this.donor = donation.donor.firstname + " " + donation.donor.lastname; }
else { this.donor = donation.donor.firstname + " " + donation.donor.middlename + " " + donation.donor.lastname; }
this.amountPerDistance = donation.amountPerDistance; this.amountPerDistance = donation.amountPerDistance;
this.amount = donation.amount; this.amount = donation.amount;
} }

View File

@ -1,51 +0,0 @@
import { IsInt, IsString } from "class-validator";
import { Donor } from '../entities/Donor';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';
/**
* Defines the donor selfservice response.
* Why? B/C runner's are not allowed to view all information available to admin users.
*/
export class ResponseSelfServiceDonor implements IResponse {
/**
* The responseType.
* This contains the type of class/entity this response contains.
*/
responseType: ResponseObjectType = ResponseObjectType.SELFSERVICEDONOR;
/**
* The participant's id.
*/
@IsInt()
id: number;
/**
* The participant's first name.
*/
@IsString()
firstname: string;
/**
* The participant's middle name.
*/
@IsString()
middlename?: string;
/**
* The participant's last name.
*/
@IsString()
lastname: string;
/**
* Creates a ResponseSelfServiceDonor object from a runner.
* @param donor The donor the response shall be build for.
*/
public constructor(donor: Donor) {
this.id = donor.id;
this.firstname = donor.firstname;
this.middlename = donor.middlename;
this.lastname = donor.lastname;
}
}

View File

@ -38,10 +38,10 @@ export class ResponseSelfServiceRunner extends ResponseParticipant implements IR
group: string; group: string;
/** /**
* The runner's associated distance donations. * The runner's associated donations.
*/ */
@IsString() @IsString()
distanceDonations: ResponseSelfServiceDonation[] donations: ResponseSelfServiceDonation[]
/** /**
* The runner's self-service jwt for auth. * The runner's self-service jwt for auth.
@ -60,7 +60,7 @@ export class ResponseSelfServiceRunner extends ResponseParticipant implements IR
this.distance = runner.distance; this.distance = runner.distance;
this.donationAmount = runner.distanceDonationAmount; this.donationAmount = runner.distanceDonationAmount;
this.group = this.getTeamString(runner.group); this.group = this.getTeamString(runner.group);
this.distanceDonations = this.getDonations(runner.distanceDonations); this.donations = this.getDonations(runner.distanceDonations);
} }
/** /**