2023-01-26 13:58:25 -06:00
|
|
|
import { ArgumentValidator } from "./ArgumentValidator";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @class PagingRequest - Paging request model
|
|
|
|
|
*/
|
2023-01-25 22:28:45 -06:00
|
|
|
export class PagingRequest {
|
2023-01-26 13:58:25 -06:00
|
|
|
/**
|
|
|
|
|
* @property {number} pageNumber - The page number of the request.
|
|
|
|
|
*/
|
2023-01-25 22:28:45 -06:00
|
|
|
pageNumber: number;
|
2023-01-26 13:58:25 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @property {number} pageSize - The page size of the request.
|
|
|
|
|
*/
|
2023-01-25 22:28:45 -06:00
|
|
|
pageSize: number;
|
|
|
|
|
|
2023-01-26 13:58:25 -06:00
|
|
|
/**
|
|
|
|
|
* @constructor - Creates a new instance of the PagingRequest class.
|
|
|
|
|
* @param {number} pageNumber - The page number of the request. Must be greater than 0.
|
|
|
|
|
* @param {number} pageSize - The page size of the request. Must be greater than 0 and less than 1001.
|
|
|
|
|
* @returns {PagingRequest} - A new instance of the PagingRequest class.
|
|
|
|
|
* @throws {Error} - Thrown when the pageNumber is less than 1.
|
|
|
|
|
* @throws {Error} - Thrown when the pageSize is less than 1.
|
|
|
|
|
* @throws {Error} - Thrown when the pageSize is greater than 1000.
|
|
|
|
|
*/
|
2023-01-25 22:28:45 -06:00
|
|
|
constructor(pageNumber: number, pageSize: number) {
|
2023-01-26 13:58:25 -06:00
|
|
|
if (ArgumentValidator.isValidPageNumber(pageNumber) === false) {
|
|
|
|
|
throw new Error("pageNumber must be greater than 0.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ArgumentValidator.isValidPageSize(pageSize) === false) {
|
|
|
|
|
throw new Error("pageSize must be greater than 0 and less than 1001.");
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-25 22:28:45 -06:00
|
|
|
this.pageNumber = pageNumber;
|
|
|
|
|
this.pageSize = pageSize;
|
|
|
|
|
}
|
|
|
|
|
}
|