parent
d12801e34d
commit
1407fe36f3
|
@ -9,6 +9,7 @@ import {
|
|||
} from "class-validator";
|
||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { config } from '../../config';
|
||||
import { ResponseGroupContact } from '../responses/ResponseGroupContact';
|
||||
import { Address } from "./Address";
|
||||
import { IAddressUser } from './IAddressUser';
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
|
@ -85,7 +86,7 @@ export class GroupContact implements IAddressUser {
|
|||
/**
|
||||
* Turns this entity into it's response class.
|
||||
*/
|
||||
public toResponse() {
|
||||
return new Error("NotImplemented");
|
||||
public toResponse(): ResponseGroupContact {
|
||||
return new ResponseGroupContact(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
import { IsInt, IsString } from "class-validator";
|
||||
import { GroupContact } from '../entities/GroupContact';
|
||||
import { ResponseRunnerGroup } from './ResponseRunnerGroup';
|
||||
|
||||
/**
|
||||
* Defines the group contact response.
|
||||
*/
|
||||
export class ResponseGroupContact {
|
||||
/**
|
||||
* The contact's id.
|
||||
*/
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The contact's first name.
|
||||
*/
|
||||
@IsString()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* The contact's middle name.
|
||||
*/
|
||||
@IsString()
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* The contact's last name.
|
||||
*/
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* The contact's phone number.
|
||||
*/
|
||||
@IsString()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The contact's e-mail address.
|
||||
*/
|
||||
@IsString()
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The contact's associated runner groups.
|
||||
*/
|
||||
groups: ResponseRunnerGroup[];
|
||||
|
||||
//TODO: Address
|
||||
|
||||
/**
|
||||
* Creates a ResponseGroupContact object from a contact.
|
||||
* @param contact The contact the response shall be build for.
|
||||
*/
|
||||
public constructor(contact: GroupContact) {
|
||||
this.id = contact.id;
|
||||
this.firstname = contact.firstname;
|
||||
this.middlename = contact.middlename;
|
||||
this.lastname = contact.lastname;
|
||||
this.phone = contact.phone;
|
||||
this.email = contact.email;
|
||||
for (let group of contact.groups) {
|
||||
this.groups.push(group.toResponse());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue