Skip to content

Commit

Permalink
fix: change search params fields to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed May 6, 2023
1 parent a5e3a5d commit 2157f80
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/anime-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('test Anime Client', () => {
});

it('should get animes filtered by params', async () => {
const params: Partial<AnimeSearchParams> = { limit: 3, score: 9 };
const params: AnimeSearchParams = { limit: 3, score: 9 };
const data = await client.getAnimeSearch(params).then((response: JikanResponse<Anime[]>) => response.data);

expect(data).toHaveLength(3);
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/manga-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('test Manga Client', () => {
});

it('should get mangas filtered by params', async () => {
const params: Partial<MangaSearchParams> = { limit: 3, score: 9 };
const params: MangaSearchParams = { limit: 3, score: 9 };
const data = await client.getMangaSearch(params).then((response: JikanResponse<Manga[]>) => response.data);

expect(data).toHaveLength(3);
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/top-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('test Top Client', () => {
});

it('should get top animes filtered by params', async () => {
const params: Partial<AnimeTopParams> = { limit: 3, filter: TopAnimeFilter.airing };
const params: AnimeTopParams = { limit: 3, filter: TopAnimeFilter.airing };
const data = await client.getTopAnime(params).then((response: JikanResponse<Anime[]>) => response.data);

expect(data).toHaveLength(3);
Expand Down
44 changes: 22 additions & 22 deletions src/models/Params/search-params.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ export enum MangaSearchOrder {
}

export interface JikanSearchParams {
q: string;
page: number;
limit: number;
score: number;
min_score: number;
max_score: number;
sfw: boolean;
genres: string;
genres_exclude: string;
sort: SortOptions | string;
letter: string;
producers: string;
start_date: string;
end_date: string;
q?: string;
page?: number;
limit?: number;
score?: number;
min_score?: number;
max_score?: number;
sfw?: boolean;
genres?: string;
genres_exclude?: string;
sort?: SortOptions | string;
letter?: string;
producers?: string;
start_date?: string;
end_date?: string;
}

/**
Expand All @@ -53,10 +53,10 @@ export interface JikanSearchParams {
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/manga/operation/getMangaSearch)
*/
export interface MangaSearchParams extends JikanSearchParams {
type: MangaType | string;
status: MangaStatus | string;
order_by: MangaSearchOrder | SearchOrder | string;
magazines: string;
type?: MangaType | string;
status?: MangaStatus | string;
order_by?: MangaSearchOrder | SearchOrder | string;
magazines?: string;
}

/**
Expand All @@ -65,8 +65,8 @@ export interface MangaSearchParams extends JikanSearchParams {
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeSearch)
*/
export interface AnimeSearchParams extends JikanSearchParams {
type: AnimeType | string;
status: AnimeStatus | string;
rating: AnimeRating | string;
order_by: AnimeSearchOrder | SearchOrder | string;
type?: AnimeType | string;
status?: AnimeStatus | string;
rating?: AnimeRating | string;
order_by?: AnimeSearchOrder | SearchOrder | string;
}
12 changes: 6 additions & 6 deletions src/models/Params/top-params.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export enum TopMangaFilter {
}

export interface JikanTopParams {
page: number;
limit: number;
page?: number;
limit?: number;
}

/**
Expand All @@ -26,8 +26,8 @@ export interface JikanTopParams {
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/top/operation/getTopAnime)
*/
export interface AnimeTopParams extends JikanTopParams {
type: AnimeType;
filter: TopAnimeFilter;
type?: AnimeType;
filter?: TopAnimeFilter;
}

/**
Expand All @@ -36,6 +36,6 @@ export interface AnimeTopParams extends JikanTopParams {
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/top/operation/getTopManga)
*/
export interface MangaTopParams extends JikanTopParams {
type: MangaType;
filter: TopMangaFilter;
type?: MangaType;
filter?: TopMangaFilter;
}

0 comments on commit 2157f80

Please sign in to comment.