Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Added DTOs for heusalagroup/hghs#10
Browse files Browse the repository at this point in the history
  • Loading branch information
thejhh committed Apr 24, 2022
1 parent dcab892 commit 9cd6058
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
38 changes: 38 additions & 0 deletions types/request/leaveRoom/MatrixLeaveRoomRequestDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2022. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.

import {
hasNoOtherKeysInDevelopment,
isRegularObject,
isStringOrUndefined
} from "../../../../core/modules/lodash";

export interface MatrixLeaveRoomRequestDTO {
readonly reason ?: string;
}

export function createMatrixLeaveRoomRequestDTO (
reason : string | undefined
): MatrixLeaveRoomRequestDTO {
return {
reason
};
}

export function isMatrixLeaveRoomRequestDTO (value: any): value is MatrixLeaveRoomRequestDTO {
return (
isRegularObject(value)
&& hasNoOtherKeysInDevelopment(value, [
'reason'
])
&& isStringOrUndefined(value?.reason)
);
}

export function stringifyMatrixLeaveRoomRequestDTO (value: MatrixLeaveRoomRequestDTO): string {
return `MatrixLeaveRoomRequestDTO(${value})`;
}

export function parseMatrixLeaveRoomRequestDTO (value: any): MatrixLeaveRoomRequestDTO | undefined {
if ( isMatrixLeaveRoomRequestDTO(value) ) return value;
return undefined;
}
26 changes: 26 additions & 0 deletions types/response/leaveRoom/MatrixLeaveRoomResponseDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2022. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.

import { hasNoOtherKeysInDevelopment, isRegularObject } from "../../../../core/modules/lodash";

export interface MatrixLeaveRoomResponseDTO {
}

export function createMatrixLeaveRoomResponseDTO (): MatrixLeaveRoomResponseDTO {
return {};
}

export function isMatrixLeaveRoomResponseDTO (value: any): value is MatrixLeaveRoomResponseDTO {
return (
isRegularObject(value)
&& hasNoOtherKeysInDevelopment(value, [])
);
}

export function stringifyMatrixLeaveRoomResponseDTO (value: MatrixLeaveRoomResponseDTO): string {
return `MatrixLeaveRoomResponseDTO(${value})`;
}

export function parseMatrixLeaveRoomResponseDTO (value: any): MatrixLeaveRoomResponseDTO | undefined {
if ( isMatrixLeaveRoomResponseDTO(value) ) return value;
return undefined;
}

0 comments on commit 9cd6058

Please sign in to comment.