2024-04-21 23:09:37 -07:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
2024-04-21 15:14:16 -07:00
|
|
|
pub use crate::APIInterface;
|
2024-06-14 20:23:44 -07:00
|
|
|
use crate::{api::http_client::Credentials, model::{Conversation, JwtToken}};
|
2024-04-21 15:14:16 -07:00
|
|
|
|
2024-04-21 23:09:37 -07:00
|
|
|
pub struct TestClient {
|
|
|
|
|
pub version: &'static str,
|
|
|
|
|
pub conversations: Vec<Conversation>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum TestError {}
|
2024-04-21 15:14:16 -07:00
|
|
|
|
2024-04-21 23:09:37 -07:00
|
|
|
impl TestClient {
|
|
|
|
|
pub fn new() -> TestClient {
|
|
|
|
|
TestClient {
|
|
|
|
|
version: "KordophoneTest-1.0",
|
|
|
|
|
conversations: vec![],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[async_trait]
|
2024-04-21 15:14:16 -07:00
|
|
|
impl APIInterface for TestClient {
|
2024-04-21 23:09:37 -07:00
|
|
|
type Error = TestError;
|
|
|
|
|
|
2024-06-14 20:23:44 -07:00
|
|
|
async fn authenticate(&mut self, credentials: Credentials) -> Result<JwtToken, Self::Error> {
|
|
|
|
|
Ok(JwtToken::dummy())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn get_version(&mut self) -> Result<String, Self::Error> {
|
2024-04-21 23:09:37 -07:00
|
|
|
Ok(self.version.to_string())
|
2024-04-21 15:14:16 -07:00
|
|
|
}
|
|
|
|
|
|
2024-06-14 20:23:44 -07:00
|
|
|
async fn get_conversations(&mut self) -> Result<Vec<Conversation>, Self::Error> {
|
2024-04-21 23:09:37 -07:00
|
|
|
Ok(self.conversations.clone())
|
2024-04-21 15:14:16 -07:00
|
|
|
}
|
|
|
|
|
}
|