// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.chronosky.plan.getUsage
//
// 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, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::app_chronosky::plan::get_usage;
/// Current plan information.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CurrentPlan<S: BosStr = DefaultStr> {
    ///Localized plan display names
    pub display_name: Data<S>,
    ///Plan ID
    pub id: S,
    ///Whether the plan is currently active
    pub is_active: bool,
    ///Internal plan name
    pub name: S,
    ///Plan tier (FREE, BASIC, STANDARD, PREMIUM)
    pub tier: S,
    ///Plan expiration date (ISO 8601)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub valid_until: Option<Datetime>,
    #[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 GetUsageOutput<S: BosStr = DefaultStr> {
    pub current_plan: get_usage::CurrentPlan<S>,
    pub limits: get_usage::PlanLimits<S>,
    pub usage: get_usage::UsageStats<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Plan limits.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PlanLimits<S: BosStr = DefaultStr> {
    ///Whether markdown formatting is supported
    #[serde(skip_serializing_if = "Option::is_none")]
    pub markdown_support: Option<bool>,
    ///Maximum image size (MB)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_image_size_mb: Option<i64>,
    ///Maximum images per post
    pub max_images_per_post: i64,
    ///Maximum days in advance to schedule
    pub max_schedule_days: i64,
    ///Maximum video size (MB)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_video_size_mb: Option<i64>,
    ///Maximum posts per month
    pub monthly_posts_limit: i64,
    ///Maximum concurrent pending posts
    pub pending_posts_limit: i64,
    ///Minimum interval between scheduled posts (minutes)
    pub schedule_interval_minutes: i64,
    ///Whether thread posts are enabled
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread_posts: Option<bool>,
    ///Maximum posts per thread
    pub thread_posts_limit: i64,
    ///Monthly video processing minutes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub video_processing_minutes_monthly: Option<i64>,
    ///Whether video uploads are enabled
    #[serde(skip_serializing_if = "Option::is_none")]
    pub video_upload: Option<bool>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Usage statistics.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UsageStats<S: BosStr = DefaultStr> {
    ///API requests in current hour
    #[serde(skip_serializing_if = "Option::is_none")]
    pub api_requests_this_hour: Option<i64>,
    ///Last time usage was updated (ISO 8601)
    pub last_updated: Datetime,
    ///End of current monthly period (ISO 8601)
    pub monthly_period_end: Datetime,
    ///Start of current monthly period (ISO 8601)
    pub monthly_period_start: Datetime,
    ///Number of posts this month
    pub monthly_posts_count: i64,
    ///Current number of pending posts
    pub pending_posts_count: i64,
    ///Storage used (MB)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub storage_used_mb: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for CurrentPlan<S> {
    fn nsid() -> &'static str {
        "app.chronosky.plan.getUsage"
    }
    fn def_name() -> &'static str {
        "currentPlan"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_plan_getUsage()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.tier;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tier"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

/** Request marker for the `app.chronosky.plan.getUsage` query.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetUsage;
/** Response marker for the `app.chronosky.plan.getUsage` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetUsageOutput<S>` for this endpoint.*/
pub struct GetUsageResponse;
impl jacquard_common::xrpc::XrpcResp for GetUsageResponse {
    const NSID: &'static str = "app.chronosky.plan.getUsage";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetUsageOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl jacquard_common::xrpc::XrpcRequest for GetUsage {
    const NSID: &'static str = "app.chronosky.plan.getUsage";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetUsageResponse;
}

/** Endpoint marker for the `app.chronosky.plan.getUsage` query.

Path: `/xrpc/app.chronosky.plan.getUsage`. The request payload type is `GetUsage`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
pub struct GetUsageRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetUsageRequest {
    const PATH: &'static str = "/xrpc/app.chronosky.plan.getUsage";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetUsage;
    type Response = GetUsageResponse;
}

impl<S: BosStr> LexiconSchema for PlanLimits<S> {
    fn nsid() -> &'static str {
        "app.chronosky.plan.getUsage"
    }
    fn def_name() -> &'static str {
        "planLimits"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_plan_getUsage()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for UsageStats<S> {
    fn nsid() -> &'static str {
        "app.chronosky.plan.getUsage"
    }
    fn def_name() -> &'static str {
        "usageStats"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_plan_getUsage()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod current_plan_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 DisplayName;
        type Id;
        type IsActive;
        type Name;
        type Tier;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type DisplayName = Unset;
        type Id = Unset;
        type IsActive = Unset;
        type Name = Unset;
        type Tier = Unset;
    }
    ///State transition - sets the `display_name` field to Set
    pub struct SetDisplayName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDisplayName<St> {}
    impl<St: State> State for SetDisplayName<St> {
        type DisplayName = Set<members::display_name>;
        type Id = St::Id;
        type IsActive = St::IsActive;
        type Name = St::Name;
        type Tier = St::Tier;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type DisplayName = St::DisplayName;
        type Id = Set<members::id>;
        type IsActive = St::IsActive;
        type Name = St::Name;
        type Tier = St::Tier;
    }
    ///State transition - sets the `is_active` field to Set
    pub struct SetIsActive<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIsActive<St> {}
    impl<St: State> State for SetIsActive<St> {
        type DisplayName = St::DisplayName;
        type Id = St::Id;
        type IsActive = Set<members::is_active>;
        type Name = St::Name;
        type Tier = St::Tier;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type DisplayName = St::DisplayName;
        type Id = St::Id;
        type IsActive = St::IsActive;
        type Name = Set<members::name>;
        type Tier = St::Tier;
    }
    ///State transition - sets the `tier` field to Set
    pub struct SetTier<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTier<St> {}
    impl<St: State> State for SetTier<St> {
        type DisplayName = St::DisplayName;
        type Id = St::Id;
        type IsActive = St::IsActive;
        type Name = St::Name;
        type Tier = Set<members::tier>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `display_name` field
        pub struct display_name(());
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `is_active` field
        pub struct is_active(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `tier` field
        pub struct tier(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CurrentPlanBuilder<St: current_plan_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Data<S>>,
        Option<S>,
        Option<bool>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl CurrentPlan<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> CurrentPlanBuilder<current_plan_state::Empty, DefaultStr> {
        CurrentPlanBuilder::new()
    }
}

impl<S: BosStr> CurrentPlan<S> {
    /// Create a new builder for this type
    pub fn builder() -> CurrentPlanBuilder<current_plan_state::Empty, S> {
        CurrentPlanBuilder::builder()
    }
}

impl CurrentPlanBuilder<current_plan_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> CurrentPlanBuilder<current_plan_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::DisplayName: current_plan_state::IsUnset,
{
    /// Set the `displayName` field (required)
    pub fn display_name(
        mut self,
        value: impl Into<Data<S>>,
    ) -> CurrentPlanBuilder<current_plan_state::SetDisplayName<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::Id: current_plan_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> CurrentPlanBuilder<current_plan_state::SetId<St>, S> {
        self._fields.1 = Option::Some(value.into());
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::IsActive: current_plan_state::IsUnset,
{
    /// Set the `isActive` field (required)
    pub fn is_active(
        mut self,
        value: impl Into<bool>,
    ) -> CurrentPlanBuilder<current_plan_state::SetIsActive<St>, S> {
        self._fields.2 = Option::Some(value.into());
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::Name: current_plan_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> CurrentPlanBuilder<current_plan_state::SetName<St>, S> {
        self._fields.3 = Option::Some(value.into());
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::Tier: current_plan_state::IsUnset,
{
    /// Set the `tier` field (required)
    pub fn tier(
        mut self,
        value: impl Into<S>,
    ) -> CurrentPlanBuilder<current_plan_state::SetTier<St>, S> {
        self._fields.4 = Option::Some(value.into());
        CurrentPlanBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: current_plan_state::State, S: BosStr> CurrentPlanBuilder<St, S> {
    /// Set the `validUntil` field (optional)
    pub fn valid_until(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `validUntil` field to an Option value (optional)
    pub fn maybe_valid_until(mut self, value: Option<Datetime>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> CurrentPlanBuilder<St, S>
where
    St: current_plan_state::State,
    St::DisplayName: current_plan_state::IsSet,
    St::Id: current_plan_state::IsSet,
    St::IsActive: current_plan_state::IsSet,
    St::Name: current_plan_state::IsSet,
    St::Tier: current_plan_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CurrentPlan<S> {
        CurrentPlan {
            display_name: self._fields.0.unwrap(),
            id: self._fields.1.unwrap(),
            is_active: self._fields.2.unwrap(),
            name: self._fields.3.unwrap(),
            tier: self._fields.4.unwrap(),
            valid_until: self._fields.5,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> CurrentPlan<S> {
        CurrentPlan {
            display_name: self._fields.0.unwrap(),
            id: self._fields.1.unwrap(),
            is_active: self._fields.2.unwrap(),
            name: self._fields.3.unwrap(),
            tier: self._fields.4.unwrap(),
            valid_until: self._fields.5,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_chronosky_plan_getUsage() -> 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("app.chronosky.plan.getUsage"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("currentPlan"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Current plan information.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("tier"),
                            SmolStr::new_static("name"),
                            SmolStr::new_static("displayName"),
                            SmolStr::new_static("isActive")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("displayName"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Plan ID")),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isActive"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Internal plan name")),
                                max_length: Some(200usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tier"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Plan tier (FREE, BASIC, STANDARD, PREMIUM)",
                                    ),
                                ),
                                max_length: Some(50usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("validUntil"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Plan expiration date (ISO 8601)"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("planLimits"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Plan limits.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("monthlyPostsLimit"),
                            SmolStr::new_static("pendingPostsLimit"),
                            SmolStr::new_static("maxScheduleDays"),
                            SmolStr::new_static("scheduleIntervalMinutes"),
                            SmolStr::new_static("maxImagesPerPost"),
                            SmolStr::new_static("threadPostsLimit")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("markdownSupport"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("maxImageSizeMb"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("maxImagesPerPost"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("maxScheduleDays"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("maxVideoSizeMb"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("monthlyPostsLimit"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("pendingPostsLimit"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("scheduleIntervalMinutes"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadPosts"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadPostsLimit"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("videoProcessingMinutesMonthly"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("videoUpload"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("usageStats"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Usage statistics.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("pendingPostsCount"),
                            SmolStr::new_static("monthlyPostsCount"),
                            SmolStr::new_static("monthlyPeriodStart"),
                            SmolStr::new_static("monthlyPeriodEnd"),
                            SmolStr::new_static("lastUpdated")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("apiRequestsThisHour"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastUpdated"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Last time usage was updated (ISO 8601)"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("monthlyPeriodEnd"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "End of current monthly period (ISO 8601)",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("monthlyPeriodStart"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Start of current monthly period (ISO 8601)",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("monthlyPostsCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("pendingPostsCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("storageUsedMb"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod plan_limits_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 MaxImagesPerPost;
        type MaxScheduleDays;
        type MonthlyPostsLimit;
        type PendingPostsLimit;
        type ScheduleIntervalMinutes;
        type ThreadPostsLimit;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type MaxImagesPerPost = Unset;
        type MaxScheduleDays = Unset;
        type MonthlyPostsLimit = Unset;
        type PendingPostsLimit = Unset;
        type ScheduleIntervalMinutes = Unset;
        type ThreadPostsLimit = Unset;
    }
    ///State transition - sets the `max_images_per_post` field to Set
    pub struct SetMaxImagesPerPost<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMaxImagesPerPost<St> {}
    impl<St: State> State for SetMaxImagesPerPost<St> {
        type MaxImagesPerPost = Set<members::max_images_per_post>;
        type MaxScheduleDays = St::MaxScheduleDays;
        type MonthlyPostsLimit = St::MonthlyPostsLimit;
        type PendingPostsLimit = St::PendingPostsLimit;
        type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
        type ThreadPostsLimit = St::ThreadPostsLimit;
    }
    ///State transition - sets the `max_schedule_days` field to Set
    pub struct SetMaxScheduleDays<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMaxScheduleDays<St> {}
    impl<St: State> State for SetMaxScheduleDays<St> {
        type MaxImagesPerPost = St::MaxImagesPerPost;
        type MaxScheduleDays = Set<members::max_schedule_days>;
        type MonthlyPostsLimit = St::MonthlyPostsLimit;
        type PendingPostsLimit = St::PendingPostsLimit;
        type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
        type ThreadPostsLimit = St::ThreadPostsLimit;
    }
    ///State transition - sets the `monthly_posts_limit` field to Set
    pub struct SetMonthlyPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMonthlyPostsLimit<St> {}
    impl<St: State> State for SetMonthlyPostsLimit<St> {
        type MaxImagesPerPost = St::MaxImagesPerPost;
        type MaxScheduleDays = St::MaxScheduleDays;
        type MonthlyPostsLimit = Set<members::monthly_posts_limit>;
        type PendingPostsLimit = St::PendingPostsLimit;
        type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
        type ThreadPostsLimit = St::ThreadPostsLimit;
    }
    ///State transition - sets the `pending_posts_limit` field to Set
    pub struct SetPendingPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPendingPostsLimit<St> {}
    impl<St: State> State for SetPendingPostsLimit<St> {
        type MaxImagesPerPost = St::MaxImagesPerPost;
        type MaxScheduleDays = St::MaxScheduleDays;
        type MonthlyPostsLimit = St::MonthlyPostsLimit;
        type PendingPostsLimit = Set<members::pending_posts_limit>;
        type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
        type ThreadPostsLimit = St::ThreadPostsLimit;
    }
    ///State transition - sets the `schedule_interval_minutes` field to Set
    pub struct SetScheduleIntervalMinutes<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetScheduleIntervalMinutes<St> {}
    impl<St: State> State for SetScheduleIntervalMinutes<St> {
        type MaxImagesPerPost = St::MaxImagesPerPost;
        type MaxScheduleDays = St::MaxScheduleDays;
        type MonthlyPostsLimit = St::MonthlyPostsLimit;
        type PendingPostsLimit = St::PendingPostsLimit;
        type ScheduleIntervalMinutes = Set<members::schedule_interval_minutes>;
        type ThreadPostsLimit = St::ThreadPostsLimit;
    }
    ///State transition - sets the `thread_posts_limit` field to Set
    pub struct SetThreadPostsLimit<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetThreadPostsLimit<St> {}
    impl<St: State> State for SetThreadPostsLimit<St> {
        type MaxImagesPerPost = St::MaxImagesPerPost;
        type MaxScheduleDays = St::MaxScheduleDays;
        type MonthlyPostsLimit = St::MonthlyPostsLimit;
        type PendingPostsLimit = St::PendingPostsLimit;
        type ScheduleIntervalMinutes = St::ScheduleIntervalMinutes;
        type ThreadPostsLimit = Set<members::thread_posts_limit>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `max_images_per_post` field
        pub struct max_images_per_post(());
        ///Marker type for the `max_schedule_days` field
        pub struct max_schedule_days(());
        ///Marker type for the `monthly_posts_limit` field
        pub struct monthly_posts_limit(());
        ///Marker type for the `pending_posts_limit` field
        pub struct pending_posts_limit(());
        ///Marker type for the `schedule_interval_minutes` field
        pub struct schedule_interval_minutes(());
        ///Marker type for the `thread_posts_limit` field
        pub struct thread_posts_limit(());
    }
}

/// Builder for constructing an instance of this type.
pub struct PlanLimitsBuilder<St: plan_limits_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<bool>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<bool>,
        Option<i64>,
        Option<i64>,
        Option<bool>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl PlanLimits<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> PlanLimitsBuilder<plan_limits_state::Empty, DefaultStr> {
        PlanLimitsBuilder::new()
    }
}

impl<S: BosStr> PlanLimits<S> {
    /// Create a new builder for this type
    pub fn builder() -> PlanLimitsBuilder<plan_limits_state::Empty, S> {
        PlanLimitsBuilder::builder()
    }
}

impl PlanLimitsBuilder<plan_limits_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> PlanLimitsBuilder<plan_limits_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `markdownSupport` field (optional)
    pub fn markdown_support(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `markdownSupport` field to an Option value (optional)
    pub fn maybe_markdown_support(mut self, value: Option<bool>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `maxImageSizeMb` field (optional)
    pub fn max_image_size_mb(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `maxImageSizeMb` field to an Option value (optional)
    pub fn maybe_max_image_size_mb(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::MaxImagesPerPost: plan_limits_state::IsUnset,
{
    /// Set the `maxImagesPerPost` field (required)
    pub fn max_images_per_post(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetMaxImagesPerPost<St>, S> {
        self._fields.2 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::MaxScheduleDays: plan_limits_state::IsUnset,
{
    /// Set the `maxScheduleDays` field (required)
    pub fn max_schedule_days(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetMaxScheduleDays<St>, S> {
        self._fields.3 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `maxVideoSizeMb` field (optional)
    pub fn max_video_size_mb(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `maxVideoSizeMb` field to an Option value (optional)
    pub fn maybe_max_video_size_mb(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::MonthlyPostsLimit: plan_limits_state::IsUnset,
{
    /// Set the `monthlyPostsLimit` field (required)
    pub fn monthly_posts_limit(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetMonthlyPostsLimit<St>, S> {
        self._fields.5 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::PendingPostsLimit: plan_limits_state::IsUnset,
{
    /// Set the `pendingPostsLimit` field (required)
    pub fn pending_posts_limit(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetPendingPostsLimit<St>, S> {
        self._fields.6 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::ScheduleIntervalMinutes: plan_limits_state::IsUnset,
{
    /// Set the `scheduleIntervalMinutes` field (required)
    pub fn schedule_interval_minutes(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetScheduleIntervalMinutes<St>, S> {
        self._fields.7 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `threadPosts` field (optional)
    pub fn thread_posts(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `threadPosts` field to an Option value (optional)
    pub fn maybe_thread_posts(mut self, value: Option<bool>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::ThreadPostsLimit: plan_limits_state::IsUnset,
{
    /// Set the `threadPostsLimit` field (required)
    pub fn thread_posts_limit(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<plan_limits_state::SetThreadPostsLimit<St>, S> {
        self._fields.9 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `videoProcessingMinutesMonthly` field (optional)
    pub fn video_processing_minutes_monthly(
        mut self,
        value: impl Into<Option<i64>>,
    ) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `videoProcessingMinutesMonthly` field to an Option value (optional)
    pub fn maybe_video_processing_minutes_monthly(mut self, value: Option<i64>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: plan_limits_state::State, S: BosStr> PlanLimitsBuilder<St, S> {
    /// Set the `videoUpload` field (optional)
    pub fn video_upload(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `videoUpload` field to an Option value (optional)
    pub fn maybe_video_upload(mut self, value: Option<bool>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> PlanLimitsBuilder<St, S>
where
    St: plan_limits_state::State,
    St::MaxImagesPerPost: plan_limits_state::IsSet,
    St::MaxScheduleDays: plan_limits_state::IsSet,
    St::MonthlyPostsLimit: plan_limits_state::IsSet,
    St::PendingPostsLimit: plan_limits_state::IsSet,
    St::ScheduleIntervalMinutes: plan_limits_state::IsSet,
    St::ThreadPostsLimit: plan_limits_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> PlanLimits<S> {
        PlanLimits {
            markdown_support: self._fields.0,
            max_image_size_mb: self._fields.1,
            max_images_per_post: self._fields.2.unwrap(),
            max_schedule_days: self._fields.3.unwrap(),
            max_video_size_mb: self._fields.4,
            monthly_posts_limit: self._fields.5.unwrap(),
            pending_posts_limit: self._fields.6.unwrap(),
            schedule_interval_minutes: self._fields.7.unwrap(),
            thread_posts: self._fields.8,
            thread_posts_limit: self._fields.9.unwrap(),
            video_processing_minutes_monthly: self._fields.10,
            video_upload: self._fields.11,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> PlanLimits<S> {
        PlanLimits {
            markdown_support: self._fields.0,
            max_image_size_mb: self._fields.1,
            max_images_per_post: self._fields.2.unwrap(),
            max_schedule_days: self._fields.3.unwrap(),
            max_video_size_mb: self._fields.4,
            monthly_posts_limit: self._fields.5.unwrap(),
            pending_posts_limit: self._fields.6.unwrap(),
            schedule_interval_minutes: self._fields.7.unwrap(),
            thread_posts: self._fields.8,
            thread_posts_limit: self._fields.9.unwrap(),
            video_processing_minutes_monthly: self._fields.10,
            video_upload: self._fields.11,
            extra_data: Some(extra_data),
        }
    }
}

pub mod usage_stats_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 LastUpdated;
        type MonthlyPeriodEnd;
        type MonthlyPeriodStart;
        type MonthlyPostsCount;
        type PendingPostsCount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type LastUpdated = Unset;
        type MonthlyPeriodEnd = Unset;
        type MonthlyPeriodStart = Unset;
        type MonthlyPostsCount = Unset;
        type PendingPostsCount = Unset;
    }
    ///State transition - sets the `last_updated` field to Set
    pub struct SetLastUpdated<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLastUpdated<St> {}
    impl<St: State> State for SetLastUpdated<St> {
        type LastUpdated = Set<members::last_updated>;
        type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
        type MonthlyPeriodStart = St::MonthlyPeriodStart;
        type MonthlyPostsCount = St::MonthlyPostsCount;
        type PendingPostsCount = St::PendingPostsCount;
    }
    ///State transition - sets the `monthly_period_end` field to Set
    pub struct SetMonthlyPeriodEnd<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMonthlyPeriodEnd<St> {}
    impl<St: State> State for SetMonthlyPeriodEnd<St> {
        type LastUpdated = St::LastUpdated;
        type MonthlyPeriodEnd = Set<members::monthly_period_end>;
        type MonthlyPeriodStart = St::MonthlyPeriodStart;
        type MonthlyPostsCount = St::MonthlyPostsCount;
        type PendingPostsCount = St::PendingPostsCount;
    }
    ///State transition - sets the `monthly_period_start` field to Set
    pub struct SetMonthlyPeriodStart<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMonthlyPeriodStart<St> {}
    impl<St: State> State for SetMonthlyPeriodStart<St> {
        type LastUpdated = St::LastUpdated;
        type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
        type MonthlyPeriodStart = Set<members::monthly_period_start>;
        type MonthlyPostsCount = St::MonthlyPostsCount;
        type PendingPostsCount = St::PendingPostsCount;
    }
    ///State transition - sets the `monthly_posts_count` field to Set
    pub struct SetMonthlyPostsCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMonthlyPostsCount<St> {}
    impl<St: State> State for SetMonthlyPostsCount<St> {
        type LastUpdated = St::LastUpdated;
        type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
        type MonthlyPeriodStart = St::MonthlyPeriodStart;
        type MonthlyPostsCount = Set<members::monthly_posts_count>;
        type PendingPostsCount = St::PendingPostsCount;
    }
    ///State transition - sets the `pending_posts_count` field to Set
    pub struct SetPendingPostsCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPendingPostsCount<St> {}
    impl<St: State> State for SetPendingPostsCount<St> {
        type LastUpdated = St::LastUpdated;
        type MonthlyPeriodEnd = St::MonthlyPeriodEnd;
        type MonthlyPeriodStart = St::MonthlyPeriodStart;
        type MonthlyPostsCount = St::MonthlyPostsCount;
        type PendingPostsCount = Set<members::pending_posts_count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `last_updated` field
        pub struct last_updated(());
        ///Marker type for the `monthly_period_end` field
        pub struct monthly_period_end(());
        ///Marker type for the `monthly_period_start` field
        pub struct monthly_period_start(());
        ///Marker type for the `monthly_posts_count` field
        pub struct monthly_posts_count(());
        ///Marker type for the `pending_posts_count` field
        pub struct pending_posts_count(());
    }
}

/// Builder for constructing an instance of this type.
pub struct UsageStatsBuilder<St: usage_stats_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<i64>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Datetime>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl UsageStats<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> UsageStatsBuilder<usage_stats_state::Empty, DefaultStr> {
        UsageStatsBuilder::new()
    }
}

impl<S: BosStr> UsageStats<S> {
    /// Create a new builder for this type
    pub fn builder() -> UsageStatsBuilder<usage_stats_state::Empty, S> {
        UsageStatsBuilder::builder()
    }
}

impl UsageStatsBuilder<usage_stats_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> UsageStatsBuilder<usage_stats_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<St: usage_stats_state::State, S: BosStr> UsageStatsBuilder<St, S> {
    /// Set the `apiRequestsThisHour` field (optional)
    pub fn api_requests_this_hour(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `apiRequestsThisHour` field to an Option value (optional)
    pub fn maybe_api_requests_this_hour(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::LastUpdated: usage_stats_state::IsUnset,
{
    /// Set the `lastUpdated` field (required)
    pub fn last_updated(
        mut self,
        value: impl Into<Datetime>,
    ) -> UsageStatsBuilder<usage_stats_state::SetLastUpdated<St>, S> {
        self._fields.1 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::MonthlyPeriodEnd: usage_stats_state::IsUnset,
{
    /// Set the `monthlyPeriodEnd` field (required)
    pub fn monthly_period_end(
        mut self,
        value: impl Into<Datetime>,
    ) -> UsageStatsBuilder<usage_stats_state::SetMonthlyPeriodEnd<St>, S> {
        self._fields.2 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::MonthlyPeriodStart: usage_stats_state::IsUnset,
{
    /// Set the `monthlyPeriodStart` field (required)
    pub fn monthly_period_start(
        mut self,
        value: impl Into<Datetime>,
    ) -> UsageStatsBuilder<usage_stats_state::SetMonthlyPeriodStart<St>, S> {
        self._fields.3 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::MonthlyPostsCount: usage_stats_state::IsUnset,
{
    /// Set the `monthlyPostsCount` field (required)
    pub fn monthly_posts_count(
        mut self,
        value: impl Into<i64>,
    ) -> UsageStatsBuilder<usage_stats_state::SetMonthlyPostsCount<St>, S> {
        self._fields.4 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::PendingPostsCount: usage_stats_state::IsUnset,
{
    /// Set the `pendingPostsCount` field (required)
    pub fn pending_posts_count(
        mut self,
        value: impl Into<i64>,
    ) -> UsageStatsBuilder<usage_stats_state::SetPendingPostsCount<St>, S> {
        self._fields.5 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: usage_stats_state::State, S: BosStr> UsageStatsBuilder<St, S> {
    /// Set the `storageUsedMb` field (optional)
    pub fn storage_used_mb(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `storageUsedMb` field to an Option value (optional)
    pub fn maybe_storage_used_mb(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> UsageStatsBuilder<St, S>
where
    St: usage_stats_state::State,
    St::LastUpdated: usage_stats_state::IsSet,
    St::MonthlyPeriodEnd: usage_stats_state::IsSet,
    St::MonthlyPeriodStart: usage_stats_state::IsSet,
    St::MonthlyPostsCount: usage_stats_state::IsSet,
    St::PendingPostsCount: usage_stats_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> UsageStats<S> {
        UsageStats {
            api_requests_this_hour: self._fields.0,
            last_updated: self._fields.1.unwrap(),
            monthly_period_end: self._fields.2.unwrap(),
            monthly_period_start: self._fields.3.unwrap(),
            monthly_posts_count: self._fields.4.unwrap(),
            pending_posts_count: self._fields.5.unwrap(),
            storage_used_mb: self._fields.6,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> UsageStats<S> {
        UsageStats {
            api_requests_this_hour: self._fields.0,
            last_updated: self._fields.1.unwrap(),
            monthly_period_end: self._fields.2.unwrap(),
            monthly_period_start: self._fields.3.unwrap(),
            monthly_posts_count: self._fields.4.unwrap(),
            pending_posts_count: self._fields.5.unwrap(),
            storage_used_mb: self._fields.6,
            extra_data: Some(extra_data),
        }
    }
}