Fix other endpoints

Signed-off-by: trivernis <trivernis@protonmail.com>
develop
trivernis 3 years ago
parent bd55b51ab4
commit 4a46397935
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -85,7 +85,8 @@ impl AnimeThemesClient {
/// Returns an entry by a given id
pub async fn entry(&self, id: u32, include: &[&str]) -> ApiResult<ThemeEntry> {
self.entry_by_id_with_include("entry", id, include).await
self.entry_by_id_with_include("animethemeentry", id, include)
.await
}
/// Returns an image by id
@ -110,12 +111,14 @@ impl AnimeThemesClient {
/// Returns a synonym by id
pub async fn synonym(&self, id: u32, include: &[&str]) -> ApiResult<AnimeSynonym> {
self.entry_by_id_with_include("synonym", id, include).await
self.entry_by_id_with_include("animesynonym", id, include)
.await
}
/// Returns a theme by id
pub async fn theme(&self, id: u32, include: &[&str]) -> ApiResult<Theme> {
self.entry_by_id_with_include("theme", id, include).await
self.entry_by_id_with_include("animetheme", id, include)
.await
}
/// Returns a video by basename

@ -0,0 +1,10 @@
pub static THEMES: &str = "animethemes";
pub static THEME: &str = "animetheme";
pub static THEME_ENTRIES: &str = "animethemeentries";
pub static SYNONYMS: &str = "animesynonyms";
pub static RESOURCES: &str = "resources";
pub static IMAGES: &str = "images";
pub static SERIES: &str = "series";
pub static SONGS: &str = "songs";
pub static VIDEOS: &str = "videos";
pub static ANIME: &str = "anime";

@ -20,4 +20,5 @@ mod utils;
pub mod client;
pub mod error;
pub mod includes;
pub mod models;

@ -18,6 +18,7 @@ pub struct Anime {
pub season: AnimeSeason,
pub synopsis: String,
pub synonyms: Option<Vec<AnimeSynonym>>,
#[serde(alias = "animethemes")]
pub themes: Option<Vec<Theme>>,
pub series: Option<Vec<Series>>,
pub resource: Option<Vec<Resource>>,
@ -51,6 +52,7 @@ pub struct Theme {
pub slug: String,
pub song: Option<Song>,
pub anime: Option<Anime>,
#[serde(alias = "animethemeentries")]
pub entries: Option<Vec<ThemeEntry>>,
}
@ -66,6 +68,7 @@ pub struct Song {
pub meta: EntryMetadata,
pub title: String,
pub artists: Option<Vec<Artist>>,
#[serde(alias = "animethemes")]
pub themes: Option<Vec<Theme>>,
}
@ -91,6 +94,7 @@ pub struct ThemeEntry {
pub spoiler: bool,
pub notes: String,
pub videos: Option<Vec<Video>>,
#[serde(alias = "animetheme")]
pub theme: Option<Theme>,
}
@ -112,6 +116,7 @@ pub struct Video {
pub source: Option<VideoSource>,
pub overlap: VideoOverlap,
pub link: String,
#[serde(alias = "animethemeentries")]
pub entries: Option<Vec<ThemeEntry>>,
}

@ -1,4 +1,5 @@
use crate::client::AnimeThemesClient;
use crate::includes::{ANIME, SONGS, THEME, THEMES, THEME_ENTRIES, VIDEOS};
#[tokio::test]
async fn it_searches() {
@ -16,7 +17,7 @@ async fn it_searches() {
async fn it_returns_anime_by_slug() {
let client = AnimeThemesClient::default();
let result = client
.anime("vivy_fluorite_eyes_song", &["themes"])
.anime("vivy_fluorite_eyes_song", &[THEMES])
.await
.unwrap();
@ -26,7 +27,7 @@ async fn it_returns_anime_by_slug() {
#[tokio::test]
async fn it_returns_artists_by_slug() {
let client = AnimeThemesClient::default();
let result = client.artist("lisa", &["songs"]).await.unwrap();
let result = client.artist("lisa", &[SONGS]).await.unwrap();
assert!(result.songs.is_some());
}
@ -34,7 +35,7 @@ async fn it_returns_artists_by_slug() {
#[tokio::test]
async fn it_returns_entries_by_id() {
let client = AnimeThemesClient::default();
let result = client.entry(11948, &["videos", "theme"]).await.unwrap();
let result = client.entry(11948, &[VIDEOS, THEME]).await.unwrap();
assert!(result.videos.is_some());
assert!(result.theme.is_some());
@ -43,7 +44,7 @@ async fn it_returns_entries_by_id() {
#[tokio::test]
async fn it_returns_images_by_id() {
let client = AnimeThemesClient::default();
let result = client.image(7247, &["anime"]).await.unwrap();
let result = client.image(7247, &[ANIME]).await.unwrap();
assert!(result.anime.is_some())
}
@ -51,7 +52,7 @@ async fn it_returns_images_by_id() {
#[tokio::test]
async fn it_returns_resources_by_id() {
let client = AnimeThemesClient::default();
let result = client.resource(3588, &["anime"]).await.unwrap();
let result = client.resource(3588, &[ANIME]).await.unwrap();
assert!(result.anime.is_some())
}
@ -59,10 +60,7 @@ async fn it_returns_resources_by_id() {
#[tokio::test]
async fn it_returns_series_by_slug() {
let client = AnimeThemesClient::default();
let result = client
.series("shingeki_no_kyojin", &["anime"])
.await
.unwrap();
let result = client.series("shingeki_no_kyojin", &[ANIME]).await.unwrap();
assert!(result.anime.is_some())
}
@ -70,7 +68,7 @@ async fn it_returns_series_by_slug() {
#[tokio::test]
async fn it_returns_synonyms_by_id() {
let client = AnimeThemesClient::default();
let result = client.synonym(2462, &["anime"]).await.unwrap();
let result = client.synonym(2462, &[ANIME]).await.unwrap();
assert!(result.anime.is_some())
}
@ -78,7 +76,7 @@ async fn it_returns_synonyms_by_id() {
#[tokio::test]
async fn it_returns_songs_by_id() {
let client = AnimeThemesClient::default();
let result = client.song(8188, &["themes"]).await.unwrap();
let result = client.song(8188, &[THEMES]).await.unwrap();
assert!(result.themes.is_some())
}
@ -86,7 +84,7 @@ async fn it_returns_songs_by_id() {
#[tokio::test]
async fn it_returns_themes_by_id() {
let client = AnimeThemesClient::default();
let result = client.theme(8187, &["entries"]).await.unwrap();
let result = client.theme(8187, &[THEME_ENTRIES]).await.unwrap();
assert!(result.entries.is_some())
}
@ -95,7 +93,7 @@ async fn it_returns_themes_by_id() {
async fn it_returns_videos_by_basename() {
let client = AnimeThemesClient::default();
let result = client
.video("KimiUso-OP2.webm", &["entries"])
.video("KimiUso-OP2.webm", &[THEME_ENTRIES])
.await
.unwrap();

Loading…
Cancel
Save