Skip to content

Commit

Permalink
feat(person.service.ts): add methods to get person by id, filters, an…
Browse files Browse the repository at this point in the history
…d search query, and awards by filters and pagination params
  • Loading branch information
mdwitr0 committed Jun 23, 2023
1 parent 92361e3 commit 7e91c25
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/services/person.service.ts
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);
}
}

0 comments on commit 7e91c25

Please sign in to comment.