use bytes;
use mobot_derive::BotRequest;
use serde::{Deserialize, Serialize};
use super::API;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct File {
pub file_id: String,
pub file_size: Option<i64>,
pub file_path: Option<String>,
}
#[derive(Debug, Serialize, Clone, BotRequest)]
pub struct GetFileRequest {
pub file_id: String,
}
impl GetFileRequest {
pub fn new(file_id: String) -> Self {
Self { file_id }
}
}
#[derive(Debug, Serialize, Clone, BotRequest)]
pub struct DownloadRequest {
pub file_path: String,
}
impl DownloadRequest {
pub fn new(file_path: String) -> Self {
Self { file_path }
}
}
impl API {
pub async fn get_file(&self, req: &GetFileRequest) -> anyhow::Result<File> {
self.client.post("getFile", req).await
}
pub async fn download_file(&self, req: &DownloadRequest) -> anyhow::Result<bytes::Bytes> {
self.client.download_file(&req.file_path).await
}
}