Skip to main content

Common Resources

This page contains common resources that will be used in the program, they are mostly shared request and response body.


Responses

SuccessResponse<T>

Successful response will be wrapped in this class

properties
  • success
    boolean
    required
    Indicates if the response is successfult or not.
  • message
    string
    required
    The success message, if any, else empty string.
  • data
    T
    The actual requested data.

ErrorResponse<T>

Failed response will be wrapped in this class, which is almost the same as the success response. We separated them in case they need to be modified differently in the future.

properties
  • success
    boolean
    required
    Indicates if the response is successfult or not.
  • message
    string
    required
    The error message, if any, else empty string.
  • data
    T
    Mostly null if there it fails.


Paging and sorting

Pagination

This class contains metadata about paging

properties
  • page
    int
    required
    min = 1
    1-index, i.e page 1 is the first page.
  • size
    int
    required
    min = 1
    The page size, currently no limit on how big it can be.
  • totalItems
    int
    read-only
    The total number of all items of search results.
  • totalPages
    int
    read-only
    The total number of pages available, it changes according to the page and size.

Sorting

This class contains metadata about sorting

properties
  • direction
    string
    required
    ASC
    DESC
    The sorting direction of that column, either one of the two values.
  • property
    string
    required
    The column / field to be sorted.

PaginationAndSorting

This class is a composition of pagination and a list of sortings

properties
  • pagination
    Pagination
    required
    The required pagination class.
  • sortings
    The list of fields to be sorted, the order of the elements matter as it will affect how to resource is sorted.

Paginated<T>

This class contains data that is paginated and sorted

properties
  • pagination
    Pagination
    required
    The required pagination class.
  • sortings
    The list of fields to be sorted, the order of the elements matter as it will affect how to resource is sorted.
  • items
    T[]
    The list of the requested resources.