Skip to content

Commit

Permalink
feat: add random client
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed May 8, 2024
1 parent 2fba166 commit 2e034d1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const animeClient = new AnimeClient({
- TopClient
- SchedulesClient
- SeasonsClient
- RandomClient
- JikanClient (Main client)

## Leave you feedback
Expand Down
1 change: 1 addition & 0 deletions src/clients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './manga.client';
export * from './schedules.client';
export * from './seasons.client';
export * from './top.client';
export * from './random.client';
35 changes: 35 additions & 0 deletions src/clients/random.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { RandomEndpoints } from '../constants';
import { Anime, Character, JikanResponse, Manga } from '../models';
import { BaseClient } from './base.client';

/**
* **Random Client**
*
* Client used to access the Random Endpoints:
*
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
*/
export class RandomClient extends BaseClient {
/**
* Get random anime
*/
public async getRandomAnime(): Promise<JikanResponse<Anime>> {
return this.getResource<JikanResponse<Anime>>(RandomEndpoints.randomAnime);
}

/**
* Get random manga
*/
public async getRandomManga(): Promise<JikanResponse<Manga>> {
return this.getResource(RandomEndpoints.randomManga);
}

/**
* Get random character
*/
public async getRandomCharacters(): Promise<
JikanResponse<Omit<Character, 'anime' | 'manga' | 'voices'>>
> {
return this.getResource(RandomEndpoints.randomManga);
}
}
1 change: 1 addition & 0 deletions src/constants/endpoints/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './genres.endpoints';
export * from './manga.endpoints';
export * from './seasons.endpoints';
export * from './top.endpoints';
export * from './random.endpoints';
5 changes: 5 additions & 0 deletions src/constants/endpoints/random.endpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const RandomEndpoints = {
randomAnime: '/random/anime',
randomManga: '/random/manga',
randomCharacters: '/random/characters',
} as const;

0 comments on commit 2e034d1

Please sign in to comment.