// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon};
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.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CurrentPlan<'a> {
    ///Localized plan display names
    #[serde(borrow)]
    pub display_name: Data<'a>,
    ///Plan ID
    #[serde(borrow)]
    pub id: CowStr<'a>,
    ///Whether the plan is currently active
    pub is_active: bool,
    ///Internal plan name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Plan tier (FREE, BASIC, STANDARD, PREMIUM)
    #[serde(borrow)]
    pub tier: CowStr<'a>,
    ///Plan expiration date (ISO 8601)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub valid_until: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetUsageOutput<'a> {
    #[serde(borrow)]
    pub current_plan: get_usage::CurrentPlan<'a>,
    #[serde(borrow)]
    pub limits: get_usage::PlanLimits<'a>,
    #[serde(borrow)]
    pub usage: get_usage::UsageStats<'a>,
}

/// Plan limits.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PlanLimits<'a> {
    ///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>,
}

/// Usage statistics.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UsageStats<'a> {
    ///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>,
}

impl<'a> LexiconSchema for CurrentPlan<'a> {
    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(())
    }
}

/// XRPC request marker type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetUsage;
/// Response type for app.chronosky.plan.getUsage
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<'de> = GetUsageOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

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 type for app.chronosky.plan.getUsage
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<'de> = GetUsage;
    type Response = GetUsageResponse;
}

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

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

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

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

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

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

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

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

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

impl<'a, S: current_plan_state::State> CurrentPlanBuilder<'a, 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<'a, S> CurrentPlanBuilder<'a, S>
where
    S: current_plan_state::State,
    S::Name: current_plan_state::IsSet,
    S::Tier: current_plan_state::IsSet,
    S::Id: current_plan_state::IsSet,
    S::DisplayName: current_plan_state::IsSet,
    S::IsActive: current_plan_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CurrentPlan<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> CurrentPlan<'a> {
        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 ThreadPostsLimit;
        type MonthlyPostsLimit;
        type ScheduleIntervalMinutes;
        type PendingPostsLimit;
        type MaxScheduleDays;
        type MaxImagesPerPost;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ThreadPostsLimit = Unset;
        type MonthlyPostsLimit = Unset;
        type ScheduleIntervalMinutes = Unset;
        type PendingPostsLimit = Unset;
        type MaxScheduleDays = Unset;
        type MaxImagesPerPost = Unset;
    }
    ///State transition - sets the `thread_posts_limit` field to Set
    pub struct SetThreadPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetThreadPostsLimit<S> {}
    impl<S: State> State for SetThreadPostsLimit<S> {
        type ThreadPostsLimit = Set<members::thread_posts_limit>;
        type MonthlyPostsLimit = S::MonthlyPostsLimit;
        type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
        type PendingPostsLimit = S::PendingPostsLimit;
        type MaxScheduleDays = S::MaxScheduleDays;
        type MaxImagesPerPost = S::MaxImagesPerPost;
    }
    ///State transition - sets the `monthly_posts_limit` field to Set
    pub struct SetMonthlyPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMonthlyPostsLimit<S> {}
    impl<S: State> State for SetMonthlyPostsLimit<S> {
        type ThreadPostsLimit = S::ThreadPostsLimit;
        type MonthlyPostsLimit = Set<members::monthly_posts_limit>;
        type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
        type PendingPostsLimit = S::PendingPostsLimit;
        type MaxScheduleDays = S::MaxScheduleDays;
        type MaxImagesPerPost = S::MaxImagesPerPost;
    }
    ///State transition - sets the `schedule_interval_minutes` field to Set
    pub struct SetScheduleIntervalMinutes<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetScheduleIntervalMinutes<S> {}
    impl<S: State> State for SetScheduleIntervalMinutes<S> {
        type ThreadPostsLimit = S::ThreadPostsLimit;
        type MonthlyPostsLimit = S::MonthlyPostsLimit;
        type ScheduleIntervalMinutes = Set<members::schedule_interval_minutes>;
        type PendingPostsLimit = S::PendingPostsLimit;
        type MaxScheduleDays = S::MaxScheduleDays;
        type MaxImagesPerPost = S::MaxImagesPerPost;
    }
    ///State transition - sets the `pending_posts_limit` field to Set
    pub struct SetPendingPostsLimit<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPendingPostsLimit<S> {}
    impl<S: State> State for SetPendingPostsLimit<S> {
        type ThreadPostsLimit = S::ThreadPostsLimit;
        type MonthlyPostsLimit = S::MonthlyPostsLimit;
        type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
        type PendingPostsLimit = Set<members::pending_posts_limit>;
        type MaxScheduleDays = S::MaxScheduleDays;
        type MaxImagesPerPost = S::MaxImagesPerPost;
    }
    ///State transition - sets the `max_schedule_days` field to Set
    pub struct SetMaxScheduleDays<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMaxScheduleDays<S> {}
    impl<S: State> State for SetMaxScheduleDays<S> {
        type ThreadPostsLimit = S::ThreadPostsLimit;
        type MonthlyPostsLimit = S::MonthlyPostsLimit;
        type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
        type PendingPostsLimit = S::PendingPostsLimit;
        type MaxScheduleDays = Set<members::max_schedule_days>;
        type MaxImagesPerPost = S::MaxImagesPerPost;
    }
    ///State transition - sets the `max_images_per_post` field to Set
    pub struct SetMaxImagesPerPost<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMaxImagesPerPost<S> {}
    impl<S: State> State for SetMaxImagesPerPost<S> {
        type ThreadPostsLimit = S::ThreadPostsLimit;
        type MonthlyPostsLimit = S::MonthlyPostsLimit;
        type ScheduleIntervalMinutes = S::ScheduleIntervalMinutes;
        type PendingPostsLimit = S::PendingPostsLimit;
        type MaxScheduleDays = S::MaxScheduleDays;
        type MaxImagesPerPost = Set<members::max_images_per_post>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `thread_posts_limit` field
        pub struct thread_posts_limit(());
        ///Marker type for the `monthly_posts_limit` field
        pub struct monthly_posts_limit(());
        ///Marker type for the `schedule_interval_minutes` field
        pub struct schedule_interval_minutes(());
        ///Marker type for the `pending_posts_limit` field
        pub struct pending_posts_limit(());
        ///Marker type for the `max_schedule_days` field
        pub struct max_schedule_days(());
        ///Marker type for the `max_images_per_post` field
        pub struct max_images_per_post(());
    }
}

/// Builder for constructing an instance of this type
pub struct PlanLimitsBuilder<'a, S: plan_limits_state::State> {
    _state: PhantomData<fn() -> S>,
    _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>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S> PlanLimitsBuilder<'a, S>
where
    S: plan_limits_state::State,
    S::MaxImagesPerPost: plan_limits_state::IsUnset,
{
    /// Set the `maxImagesPerPost` field (required)
    pub fn max_images_per_post(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<'a, plan_limits_state::SetMaxImagesPerPost<S>> {
        self._fields.2 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S> PlanLimitsBuilder<'a, S>
where
    S: plan_limits_state::State,
    S::MonthlyPostsLimit: plan_limits_state::IsUnset,
{
    /// Set the `monthlyPostsLimit` field (required)
    pub fn monthly_posts_limit(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<'a, plan_limits_state::SetMonthlyPostsLimit<S>> {
        self._fields.5 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S> PlanLimitsBuilder<'a, S>
where
    S: plan_limits_state::State,
    S::ThreadPostsLimit: plan_limits_state::IsUnset,
{
    /// Set the `threadPostsLimit` field (required)
    pub fn thread_posts_limit(
        mut self,
        value: impl Into<i64>,
    ) -> PlanLimitsBuilder<'a, plan_limits_state::SetThreadPostsLimit<S>> {
        self._fields.9 = Option::Some(value.into());
        PlanLimitsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S: plan_limits_state::State> PlanLimitsBuilder<'a, 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<'a, S> PlanLimitsBuilder<'a, S>
where
    S: plan_limits_state::State,
    S::ThreadPostsLimit: plan_limits_state::IsSet,
    S::MonthlyPostsLimit: plan_limits_state::IsSet,
    S::ScheduleIntervalMinutes: plan_limits_state::IsSet,
    S::PendingPostsLimit: plan_limits_state::IsSet,
    S::MaxScheduleDays: plan_limits_state::IsSet,
    S::MaxImagesPerPost: plan_limits_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> PlanLimits<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> PlanLimits<'a> {
        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 PendingPostsCount;
        type MonthlyPostsCount;
        type MonthlyPeriodEnd;
        type LastUpdated;
        type MonthlyPeriodStart;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type PendingPostsCount = Unset;
        type MonthlyPostsCount = Unset;
        type MonthlyPeriodEnd = Unset;
        type LastUpdated = Unset;
        type MonthlyPeriodStart = Unset;
    }
    ///State transition - sets the `pending_posts_count` field to Set
    pub struct SetPendingPostsCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPendingPostsCount<S> {}
    impl<S: State> State for SetPendingPostsCount<S> {
        type PendingPostsCount = Set<members::pending_posts_count>;
        type MonthlyPostsCount = S::MonthlyPostsCount;
        type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
        type LastUpdated = S::LastUpdated;
        type MonthlyPeriodStart = S::MonthlyPeriodStart;
    }
    ///State transition - sets the `monthly_posts_count` field to Set
    pub struct SetMonthlyPostsCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMonthlyPostsCount<S> {}
    impl<S: State> State for SetMonthlyPostsCount<S> {
        type PendingPostsCount = S::PendingPostsCount;
        type MonthlyPostsCount = Set<members::monthly_posts_count>;
        type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
        type LastUpdated = S::LastUpdated;
        type MonthlyPeriodStart = S::MonthlyPeriodStart;
    }
    ///State transition - sets the `monthly_period_end` field to Set
    pub struct SetMonthlyPeriodEnd<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMonthlyPeriodEnd<S> {}
    impl<S: State> State for SetMonthlyPeriodEnd<S> {
        type PendingPostsCount = S::PendingPostsCount;
        type MonthlyPostsCount = S::MonthlyPostsCount;
        type MonthlyPeriodEnd = Set<members::monthly_period_end>;
        type LastUpdated = S::LastUpdated;
        type MonthlyPeriodStart = S::MonthlyPeriodStart;
    }
    ///State transition - sets the `last_updated` field to Set
    pub struct SetLastUpdated<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLastUpdated<S> {}
    impl<S: State> State for SetLastUpdated<S> {
        type PendingPostsCount = S::PendingPostsCount;
        type MonthlyPostsCount = S::MonthlyPostsCount;
        type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
        type LastUpdated = Set<members::last_updated>;
        type MonthlyPeriodStart = S::MonthlyPeriodStart;
    }
    ///State transition - sets the `monthly_period_start` field to Set
    pub struct SetMonthlyPeriodStart<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMonthlyPeriodStart<S> {}
    impl<S: State> State for SetMonthlyPeriodStart<S> {
        type PendingPostsCount = S::PendingPostsCount;
        type MonthlyPostsCount = S::MonthlyPostsCount;
        type MonthlyPeriodEnd = S::MonthlyPeriodEnd;
        type LastUpdated = S::LastUpdated;
        type MonthlyPeriodStart = Set<members::monthly_period_start>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `pending_posts_count` field
        pub struct pending_posts_count(());
        ///Marker type for the `monthly_posts_count` field
        pub struct monthly_posts_count(());
        ///Marker type for the `monthly_period_end` field
        pub struct monthly_period_end(());
        ///Marker type for the `last_updated` field
        pub struct last_updated(());
        ///Marker type for the `monthly_period_start` field
        pub struct monthly_period_start(());
    }
}

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

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

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

impl<'a, S: usage_stats_state::State> UsageStatsBuilder<'a, 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<'a, S> UsageStatsBuilder<'a, S>
where
    S: usage_stats_state::State,
    S::LastUpdated: usage_stats_state::IsUnset,
{
    /// Set the `lastUpdated` field (required)
    pub fn last_updated(
        mut self,
        value: impl Into<Datetime>,
    ) -> UsageStatsBuilder<'a, usage_stats_state::SetLastUpdated<S>> {
        self._fields.1 = Option::Some(value.into());
        UsageStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

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

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

impl<'a, S: usage_stats_state::State> UsageStatsBuilder<'a, 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<'a, S> UsageStatsBuilder<'a, S>
where
    S: usage_stats_state::State,
    S::PendingPostsCount: usage_stats_state::IsSet,
    S::MonthlyPostsCount: usage_stats_state::IsSet,
    S::MonthlyPeriodEnd: usage_stats_state::IsSet,
    S::LastUpdated: usage_stats_state::IsSet,
    S::MonthlyPeriodStart: usage_stats_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> UsageStats<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> UsageStats<'a> {
        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),
        }
    }
}