Added error handling and now possible to post employees

This commit is contained in:
Erik Tiekstra
2021-05-12 10:34:10 +02:00
parent eb18ea03a2
commit e21757b8e8
31 changed files with 27107 additions and 203 deletions

View File

@@ -1,27 +1,72 @@
import { mapPegaAccessGroupToAccessGroups, PegaAccessGroup } from '@dafa-enums/access-group.enum';
import { Agency } from '@dafa-models/agency.model';
import { EmployeeResponse } from './api/employee-response.model';
import { Participant } from './participant.model';
import { User } from './user.model';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Employee extends User {}
export interface EmployeeDetail extends Employee {
export interface Employee extends User {
languages: string[];
outOfOffice: {
start: Date;
end: Date;
}[];
authorisations: string[];
phone: string;
email: string;
ssn: string;
agencies: Agency[];
participants: Participant[];
}
export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee {
export interface EmployeesApiResponse {
pxMore: string;
pxObjClass: string;
pxPageCount: string;
pxQueryTimeStamp: string;
pxResultCount: string;
pxTotalResultCount: string;
pyMaxRecords: string;
pyObjClass: string;
pxResults: EmployeeApiResponse[];
pzPerformanceSettings: string[];
}
export interface EmployeeApiResponse {
pxInsHandle: string;
pxObjClass: string;
pyAccessGroup: string;
pyFirstName: string;
pyLastName: string;
pyOrganization: string;
pyOrgDivision: string;
pyOrgUnit: string;
pyTelephone: string;
pyUserIdentifier: string;
pyUserName: string;
}
export interface EmployeeApiRequestData {
pyFirstName: string;
pyLastName: string;
pyTelephone: string;
}
export interface EmployeeApiPostResponse {
pxObjClass: string;
pyErrorMessage: string;
pyFirstName: string;
pyHasError: 'true' | 'false';
pyLastName: string;
pyTelephone: string;
pyUserIdentifier: string;
}
export function mapEmployeeToEmployeeApiRequestData(data: Employee): EmployeeApiRequestData {
return {
pyFirstName: data.firstName,
pyLastName: data.lastName,
pyTelephone: data.phone,
};
}
export function mapEmployeeReponseToEmployee(data: EmployeeApiResponse): Employee {
return {
id: data.pyUserIdentifier,
lastName: data.pyLastName,
@@ -35,5 +80,10 @@ export function mapEmployeeReponseToEmployee(data: EmployeeResponse): Employee {
accessGroups: mapPegaAccessGroupToAccessGroups(data.pyAccessGroup as PegaAccessGroup),
utforandeverksamhet: '',
service: '',
languages: [],
outOfOffice: null,
ssn: '',
agencies: [],
participants: [],
};
}