client: implements send_message
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
use async_trait::async_trait;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use time::OffsetDateTime;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use crate::APIInterface;
|
||||
use crate::{
|
||||
api::http_client::Credentials,
|
||||
model::{Conversation, ConversationID, JwtToken, Message, MessageID, UpdateItem, Event},
|
||||
model::{Conversation, ConversationID, JwtToken, Message, MessageID, UpdateItem, Event, OutgoingMessage},
|
||||
api::event_socket::EventSocket,
|
||||
};
|
||||
|
||||
@@ -88,6 +91,20 @@ impl APIInterface for TestClient {
|
||||
Err(TestError::ConversationNotFound)
|
||||
}
|
||||
|
||||
async fn send_message(
|
||||
&mut self,
|
||||
outgoing_message: OutgoingMessage,
|
||||
) -> Result<Message, Self::Error> {
|
||||
let message = Message::builder()
|
||||
.guid(Uuid::new_v4().to_string())
|
||||
.text(outgoing_message.text)
|
||||
.date(OffsetDateTime::now_utc())
|
||||
.build();
|
||||
|
||||
self.messages.entry(outgoing_message.conversation_id).or_insert(vec![]).push(message.clone());
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
async fn open_event_socket(&mut self) -> Result<impl EventSocket, Self::Error> {
|
||||
Ok(TestEventSocket::new())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user