client: implements send_message
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
pub mod conversation;
|
||||
pub mod event;
|
||||
pub mod message;
|
||||
pub mod outgoing_message;
|
||||
pub mod update;
|
||||
|
||||
pub use conversation::Conversation;
|
||||
@@ -9,6 +10,9 @@ pub use conversation::ConversationID;
|
||||
pub use message::Message;
|
||||
pub use message::MessageID;
|
||||
|
||||
pub use outgoing_message::OutgoingMessage;
|
||||
pub use outgoing_message::OutgoingMessageBuilder;
|
||||
|
||||
pub use update::UpdateItem;
|
||||
|
||||
pub use event::Event;
|
||||
|
||||
56
kordophone/src/model/outgoing_message.rs
Normal file
56
kordophone/src/model/outgoing_message.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use serde::Serialize;
|
||||
use super::conversation::ConversationID;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct OutgoingMessage {
|
||||
#[serde(rename = "body")]
|
||||
pub text: String,
|
||||
|
||||
#[serde(rename = "guid")]
|
||||
pub conversation_id: ConversationID,
|
||||
|
||||
#[serde(rename = "fileTransferGUIDs")]
|
||||
pub file_transfer_guids: Vec<String>,
|
||||
}
|
||||
|
||||
impl OutgoingMessage {
|
||||
pub fn builder() -> OutgoingMessageBuilder {
|
||||
OutgoingMessageBuilder::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OutgoingMessageBuilder {
|
||||
text: Option<String>,
|
||||
conversation_id: Option<ConversationID>,
|
||||
file_transfer_guids: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl OutgoingMessageBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn text(mut self, text: String) -> Self {
|
||||
self.text = Some(text);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn conversation_id(mut self, conversation_id: ConversationID) -> Self {
|
||||
self.conversation_id = Some(conversation_id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_transfer_guids(mut self, file_transfer_guids: Vec<String>) -> Self {
|
||||
self.file_transfer_guids = Some(file_transfer_guids);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> OutgoingMessage {
|
||||
OutgoingMessage {
|
||||
text: self.text.unwrap(),
|
||||
conversation_id: self.conversation_id.unwrap(),
|
||||
file_transfer_guids: self.file_transfer_guids.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user