import type { ContractAttributes, Review, Stay } from '@entities' import { endpointMaker } from '@services' import type { FilterType, HttpClient, IncludeType } from '@services' import type { ApiError, Response } from '@types' export type GetReviewsInput = { houseId: string included?: { includes?: IncludeType filter?: FilterType pagination?: { per: string page: string } } } type ContractPick = Pick< ContractAttributes, | 'clientCompanyRepresentativeFirstname' | 'clientCompanyRepresentativeLastname' | 'clientFirstname' | 'clientLastname' | 'clientIsCompany' > type GetReviewIncluded = { stays: Stay | Stay[] contracts: ContractPick | ContractPick[] } const getReviews = (http: HttpClient) => ({ query: ( input: GetReviewsInput, ): Promise> => { const query = endpointMaker({ filter: input.included?.filter, includes: input.included?.includes, pagination: input.included?.pagination, }) return http.get(`v3/admin/houses/${input.houseId}/reviews${query}`) }, }) export default getReviews