#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
use crate::chat_bsky::convo::MessageInput;
use crate::chat_bsky::convo::MessageView;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SendMessage<S: BosStr = DefaultStr> {
pub convo_id: S,
pub message: MessageInput<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SendMessageOutput<S: BosStr = DefaultStr> {
#[serde(flatten)]
pub value: MessageView<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct SendMessageResponse;
impl jacquard_common::xrpc::XrpcResp for SendMessageResponse {
const NSID: &'static str = "chat.bsky.convo.sendMessage";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = SendMessageOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for SendMessage<S> {
const NSID: &'static str = "chat.bsky.convo.sendMessage";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = SendMessageResponse;
}
pub struct SendMessageRequest;
impl jacquard_common::xrpc::XrpcEndpoint for SendMessageRequest {
const PATH: &'static str = "/xrpc/chat.bsky.convo.sendMessage";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = SendMessage<S>;
type Response = SendMessageResponse;
}
pub mod send_message_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Message;
type ConvoId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Message = Unset;
type ConvoId = Unset;
}
pub struct SetMessage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMessage<St> {}
impl<St: State> State for SetMessage<St> {
type Message = Set<members::message>;
type ConvoId = St::ConvoId;
}
pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetConvoId<St> {}
impl<St: State> State for SetConvoId<St> {
type Message = St::Message;
type ConvoId = Set<members::convo_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct message(());
pub struct convo_id(());
}
}
pub struct SendMessageBuilder<S: BosStr, St: send_message_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<MessageInput<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SendMessage<S> {
pub fn new() -> SendMessageBuilder<S, send_message_state::Empty> {
SendMessageBuilder::new()
}
}
impl<S: BosStr> SendMessageBuilder<S, send_message_state::Empty> {
pub fn new() -> Self {
SendMessageBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SendMessageBuilder<S, St>
where
St: send_message_state::State,
St::ConvoId: send_message_state::IsUnset,
{
pub fn convo_id(
mut self,
value: impl Into<S>,
) -> SendMessageBuilder<S, send_message_state::SetConvoId<St>> {
self._fields.0 = Option::Some(value.into());
SendMessageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SendMessageBuilder<S, St>
where
St: send_message_state::State,
St::Message: send_message_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<MessageInput<S>>,
) -> SendMessageBuilder<S, send_message_state::SetMessage<St>> {
self._fields.1 = Option::Some(value.into());
SendMessageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SendMessageBuilder<S, St>
where
St: send_message_state::State,
St::Message: send_message_state::IsSet,
St::ConvoId: send_message_state::IsSet,
{
pub fn build(self) -> SendMessage<S> {
SendMessage {
convo_id: self._fields.0.unwrap(),
message: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> SendMessage<S> {
SendMessage {
convo_id: self._fields.0.unwrap(),
message: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}