// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.contact.sendNotification
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SendNotification<'a> {
    ///The DID of who this notification comes from.
    #[serde(borrow)]
    pub from: Did<'a>,
    ///The DID of who this notification should go to.
    #[serde(borrow)]
    pub to: Did<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SendNotificationOutput<'a> {}
/// Response type for app.bsky.contact.sendNotification
pub struct SendNotificationResponse;
impl jacquard_common::xrpc::XrpcResp for SendNotificationResponse {
    const NSID: &'static str = "app.bsky.contact.sendNotification";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = SendNotificationOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for SendNotification<'a> {
    const NSID: &'static str = "app.bsky.contact.sendNotification";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = SendNotificationResponse;
}

/// Endpoint type for app.bsky.contact.sendNotification
pub struct SendNotificationRequest;
impl jacquard_common::xrpc::XrpcEndpoint for SendNotificationRequest {
    const PATH: &'static str = "/xrpc/app.bsky.contact.sendNotification";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = SendNotification<'de>;
    type Response = SendNotificationResponse;
}

pub mod send_notification_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type To;
        type From;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type To = Unset;
        type From = Unset;
    }
    ///State transition - sets the `to` field to Set
    pub struct SetTo<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTo<S> {}
    impl<S: State> State for SetTo<S> {
        type To = Set<members::to>;
        type From = S::From;
    }
    ///State transition - sets the `from` field to Set
    pub struct SetFrom<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFrom<S> {}
    impl<S: State> State for SetFrom<S> {
        type To = S::To;
        type From = Set<members::from>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `to` field
        pub struct to(());
        ///Marker type for the `from` field
        pub struct from(());
    }
}

/// Builder for constructing an instance of this type
pub struct SendNotificationBuilder<'a, S: send_notification_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Did<'a>>, Option<Did<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SendNotification<'a> {
    /// Create a new builder for this type
    pub fn new() -> SendNotificationBuilder<'a, send_notification_state::Empty> {
        SendNotificationBuilder::new()
    }
}

impl<'a> SendNotificationBuilder<'a, send_notification_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SendNotificationBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SendNotificationBuilder<'a, S>
where
    S: send_notification_state::State,
    S::From: send_notification_state::IsUnset,
{
    /// Set the `from` field (required)
    pub fn from(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> SendNotificationBuilder<'a, send_notification_state::SetFrom<S>> {
        self._fields.0 = Option::Some(value.into());
        SendNotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SendNotificationBuilder<'a, S>
where
    S: send_notification_state::State,
    S::To: send_notification_state::IsUnset,
{
    /// Set the `to` field (required)
    pub fn to(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> SendNotificationBuilder<'a, send_notification_state::SetTo<S>> {
        self._fields.1 = Option::Some(value.into());
        SendNotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SendNotificationBuilder<'a, S>
where
    S: send_notification_state::State,
    S::To: send_notification_state::IsSet,
    S::From: send_notification_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SendNotification<'a> {
        SendNotification {
            from: self._fields.0.unwrap(),
            to: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SendNotification<'a> {
        SendNotification {
            from: self._fields.0.unwrap(),
            to: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}