-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(person.service.ts): add methods to get person by id, filters, an…
…d search query, and awards by filters and pagination params
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
import { ClientRequest } from '../client-request'; | ||
import { IResponse } from '../interfaces/response.interface'; | ||
import { | ||
Person, | ||
PersonAwardDocsResponseDto, | ||
PersonDocsResponseDto, | ||
SearchPersonResponseDto, | ||
} from '../interfaces/api.interface'; | ||
import { VERSIONS } from '../enums/version.enum'; | ||
import { IPagination } from '../interfaces/pagination.interface'; | ||
|
||
export class PersonService { | ||
constructor(private readonly request: ClientRequest) {} | ||
|
||
async getById(id: number): Promise<IResponse<Person>> { | ||
return await this.request.get(VERSIONS.V1, `/person/${id}`); | ||
} | ||
|
||
async getByFilters( | ||
filters: Record<string, string>, | ||
): Promise<IResponse<PersonDocsResponseDto>> { | ||
return await this.request.get(VERSIONS.V1, `/person`, filters); | ||
} | ||
|
||
async getBySearchQuery( | ||
query: string, | ||
): Promise<IResponse<SearchPersonResponseDto>> { | ||
return await this.request.get(VERSIONS.V1_2, `/person/search`, { | ||
query, | ||
}); | ||
} | ||
|
||
async getAwardsByFilters( | ||
filters: Record<string, string>, | ||
paginationParams?: IPagination, | ||
): Promise<IResponse<PersonAwardDocsResponseDto>> { | ||
return await this.request.get(VERSIONS.V1_1, `/movie/awards`, filters); | ||
} | ||
} |