use crate::base::TMDB;
use std::collections::HashMap;
use serde_json::Value;
pub struct Search {
tmdb: TMDB,
}
impl Search {
pub fn new() -> Self {
let mut tmdb = TMDB::new();
tmdb.base_path = "search".to_string();
tmdb.urls = [
("company".to_string(), "/company".to_string()),
("collection".to_string(), "/collection".to_string()),
("keyword".to_string(), "/keyword".to_string()),
("movie".to_string(), "/movie".to_string()),
("multi".to_string(), "/multi".to_string()),
("person".to_string(), "/person".to_string()),
("tv".to_string(), "/tv".to_string()),
]
.iter()
.cloned()
.collect();
Search { tmdb }
}
pub async fn company(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("company");
self.tmdb._get(&path, options).await
}
pub async fn collection(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("collection");
self.tmdb._get(&path, options).await
}
pub async fn keyword(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("keyword");
self.tmdb._get(&path, options).await
}
pub async fn movie(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("movie");
self.tmdb._get(&path, options).await
}
pub async fn multi(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("multi");
self.tmdb._get(&path, options).await
}
pub async fn person(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("person");
self.tmdb._get(&path, options).await
}
pub async fn tv(&self, options: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
let path = self.tmdb._get_path("tv");
self.tmdb._get(&path, options).await
}
}