// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.hosting.getAccountHistory
//
// 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::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Handle, Datetime};
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::hosting::get_account_history;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct AccountCreated<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub email: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub handle: Option<Handle<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct EmailConfirmed<'a> {
    #[serde(borrow)]
    pub email: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct EmailUpdated<'a> {
    #[serde(borrow)]
    pub email: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Event<'a> {
    pub created_at: Datetime,
    #[serde(borrow)]
    pub created_by: CowStr<'a>,
    #[serde(borrow)]
    pub details: EventDetails<'a>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum EventDetails<'a> {
    #[serde(rename = "tools.ozone.hosting.getAccountHistory#accountCreated")]
    AccountCreated(Box<get_account_history::AccountCreated<'a>>),
    #[serde(rename = "tools.ozone.hosting.getAccountHistory#emailUpdated")]
    EmailUpdated(Box<get_account_history::EmailUpdated<'a>>),
    #[serde(rename = "tools.ozone.hosting.getAccountHistory#emailConfirmed")]
    EmailConfirmed(Box<get_account_history::EmailConfirmed<'a>>),
    #[serde(rename = "tools.ozone.hosting.getAccountHistory#passwordUpdated")]
    PasswordUpdated(Box<get_account_history::PasswordUpdated<'a>>),
    #[serde(rename = "tools.ozone.hosting.getAccountHistory#handleUpdated")]
    HandleUpdated(Box<get_account_history::HandleUpdated<'a>>),
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct HandleUpdated<'a> {
    #[serde(borrow)]
    pub handle: Handle<'a>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountHistory<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub did: Did<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub events: Option<Vec<CowStr<'a>>>,
    ///Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountHistoryOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub events: Vec<get_account_history::Event<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct PasswordUpdated<'a> {}
impl<'a> LexiconSchema for AccountCreated<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "accountCreated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for EmailConfirmed<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "emailConfirmed"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for EmailUpdated<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "emailUpdated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Event<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "event"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for HandleUpdated<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "handleUpdated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// Response type for tools.ozone.hosting.getAccountHistory
pub struct GetAccountHistoryResponse;
impl jacquard_common::xrpc::XrpcResp for GetAccountHistoryResponse {
    const NSID: &'static str = "tools.ozone.hosting.getAccountHistory";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetAccountHistoryOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetAccountHistory<'a> {
    const NSID: &'static str = "tools.ozone.hosting.getAccountHistory";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetAccountHistoryResponse;
}

/// Endpoint type for tools.ozone.hosting.getAccountHistory
pub struct GetAccountHistoryRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetAccountHistoryRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.hosting.getAccountHistory";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetAccountHistory<'de>;
    type Response = GetAccountHistoryResponse;
}

impl<'a> LexiconSchema for PasswordUpdated<'a> {
    fn nsid() -> &'static str {
        "tools.ozone.hosting.getAccountHistory"
    }
    fn def_name() -> &'static str {
        "passwordUpdated"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_hosting_getAccountHistory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_tools_ozone_hosting_getAccountHistory() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("tools.ozone.hosting.getAccountHistory"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("accountCreated"),
                LexUserType::Object(LexObject {
                    required: Some(vec![]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Handle),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("emailConfirmed"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("email")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("emailUpdated"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("email")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("event"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("details"),
                            SmolStr::new_static("createdBy"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdBy"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("details"),
                            LexObjectProperty::Union(LexRefUnion {
                                refs: vec![
                                    CowStr::new_static("#accountCreated"),
                                    CowStr::new_static("#emailUpdated"),
                                    CowStr::new_static("#emailConfirmed"),
                                    CowStr::new_static("#passwordUpdated"),
                                    CowStr::new_static("#handleUpdated")
                                ],
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("handleUpdated"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("handle")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Handle),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("did")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("did"),
                                    LexXrpcParametersProperty::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("events"),
                                    LexXrpcParametersProperty::Array(LexPrimitiveArray {
                                        items: LexPrimitiveArrayItem::String(LexString {
                                            ..Default::default()
                                        }),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("passwordUpdated"),
                LexUserType::Object(LexObject {
                    required: Some(vec![]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod event_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 CreatedAt;
        type Details;
        type CreatedBy;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Details = Unset;
        type CreatedBy = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type CreatedAt = Set<members::created_at>;
        type Details = S::Details;
        type CreatedBy = S::CreatedBy;
    }
    ///State transition - sets the `details` field to Set
    pub struct SetDetails<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDetails<S> {}
    impl<S: State> State for SetDetails<S> {
        type CreatedAt = S::CreatedAt;
        type Details = Set<members::details>;
        type CreatedBy = S::CreatedBy;
    }
    ///State transition - sets the `created_by` field to Set
    pub struct SetCreatedBy<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedBy<S> {}
    impl<S: State> State for SetCreatedBy<S> {
        type CreatedAt = S::CreatedAt;
        type Details = S::Details;
        type CreatedBy = Set<members::created_by>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `details` field
        pub struct details(());
        ///Marker type for the `created_by` field
        pub struct created_by(());
    }
}

/// Builder for constructing an instance of this type
pub struct EventBuilder<'a, S: event_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>, Option<CowStr<'a>>, Option<EventDetails<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Event<'a> {
    /// Create a new builder for this type
    pub fn new() -> EventBuilder<'a, event_state::Empty> {
        EventBuilder::new()
    }
}

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

impl<'a, S> EventBuilder<'a, S>
where
    S: event_state::State,
    S::CreatedAt: event_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> EventBuilder<'a, event_state::SetCreatedAt<S>> {
        self._fields.0 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> EventBuilder<'a, S>
where
    S: event_state::State,
    S::CreatedBy: event_state::IsUnset,
{
    /// Set the `createdBy` field (required)
    pub fn created_by(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> EventBuilder<'a, event_state::SetCreatedBy<S>> {
        self._fields.1 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> EventBuilder<'a, S>
where
    S: event_state::State,
    S::Details: event_state::IsUnset,
{
    /// Set the `details` field (required)
    pub fn details(
        mut self,
        value: impl Into<EventDetails<'a>>,
    ) -> EventBuilder<'a, event_state::SetDetails<S>> {
        self._fields.2 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> EventBuilder<'a, S>
where
    S: event_state::State,
    S::CreatedAt: event_state::IsSet,
    S::Details: event_state::IsSet,
    S::CreatedBy: event_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Event<'a> {
        Event {
            created_at: self._fields.0.unwrap(),
            created_by: self._fields.1.unwrap(),
            details: self._fields.2.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>,
        >,
    ) -> Event<'a> {
        Event {
            created_at: self._fields.0.unwrap(),
            created_by: self._fields.1.unwrap(),
            details: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod handle_updated_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 Handle;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Handle = Unset;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHandle<S> {}
    impl<S: State> State for SetHandle<S> {
        type Handle = Set<members::handle>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `handle` field
        pub struct handle(());
    }
}

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

impl<'a> HandleUpdated<'a> {
    /// Create a new builder for this type
    pub fn new() -> HandleUpdatedBuilder<'a, handle_updated_state::Empty> {
        HandleUpdatedBuilder::new()
    }
}

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

impl<'a, S> HandleUpdatedBuilder<'a, S>
where
    S: handle_updated_state::State,
    S::Handle: handle_updated_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<Handle<'a>>,
    ) -> HandleUpdatedBuilder<'a, handle_updated_state::SetHandle<S>> {
        self._fields.0 = Option::Some(value.into());
        HandleUpdatedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> HandleUpdatedBuilder<'a, S>
where
    S: handle_updated_state::State,
    S::Handle: handle_updated_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> HandleUpdated<'a> {
        HandleUpdated {
            handle: self._fields.0.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>,
        >,
    ) -> HandleUpdated<'a> {
        HandleUpdated {
            handle: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn _default_limit() -> Option<i64> {
    Some(50i64)
}

pub mod get_account_history_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 Did;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Did = Unset;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDid<S> {}
    impl<S: State> State for SetDid<S> {
        type Did = Set<members::did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `did` field
        pub struct did(());
    }
}

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

impl<'a> GetAccountHistory<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetAccountHistoryBuilder<'a, get_account_history_state::Empty> {
        GetAccountHistoryBuilder::new()
    }
}

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

impl<'a, S: get_account_history_state::State> GetAccountHistoryBuilder<'a, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S: get_account_history_state::State> GetAccountHistoryBuilder<'a, S> {
    /// Set the `events` field (optional)
    pub fn events(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `events` field to an Option value (optional)
    pub fn maybe_events(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: get_account_history_state::State> GetAccountHistoryBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> GetAccountHistoryBuilder<'a, S>
where
    S: get_account_history_state::State,
    S::Did: get_account_history_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetAccountHistory<'a> {
        GetAccountHistory {
            cursor: self._fields.0,
            did: self._fields.1.unwrap(),
            events: self._fields.2,
            limit: self._fields.3,
        }
    }
}