Switched selfservice donation.donor from string to object
All checks were successful
continuous-integration/drone/pr Build is passing

ref #187
This commit is contained in:
Nicolai Ort 2021-04-03 17:07:44 +02:00
parent ca87774767
commit 0767943721

View File

@ -2,6 +2,7 @@ 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.
@ -18,7 +19,7 @@ export class ResponseSelfServiceDonation implements IResponse {
* The donation's donor. * The donation's donor.
*/ */
@IsNotEmpty() @IsNotEmpty()
donor: string; donor: ResponseSelfServiceDonor;
/** /**
* 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).
@ -35,9 +36,7 @@ export class ResponseSelfServiceDonation implements IResponse {
amountPerDistance: number; amountPerDistance: number;
public constructor(donation: DistanceDonation) { public constructor(donation: DistanceDonation) {
if (!donation.donor.middlename) { this.donor = donation.donor.firstname + " " + donation.donor.lastname; } this.donor = new ResponseSelfServiceDonor(donation.donor);
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;
} }