// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.ocho.payment.getStripeIntent
//
// 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};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetStripeIntent<S: BosStr = DefaultStr> {
    pub amount: i64,
    pub id: S,
    pub iss: Did<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub token: Option<S>,
}

/// The intent data

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetStripeIntentOutput<S: BosStr = DefaultStr> {
    ///The customer ID for the payment intent
    pub customer: S,
    ///The customer session ID for the payment intent
    pub customer_session: S,
    ///The ephemeral key for the payment intent
    pub ephemeral_key: S,
    ///The payment intent ID
    pub payment_intent: S,
    ///The publishable key for the payment intent
    pub publishable_key: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `app.ocho.payment.getStripeIntent` query.

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

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetStripeIntent<S> {
    const NSID: &'static str = "app.ocho.payment.getStripeIntent";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetStripeIntentResponse;
}

/** Endpoint marker for the `app.ocho.payment.getStripeIntent` query.

Path: `/xrpc/app.ocho.payment.getStripeIntent`. The request payload type is `GetStripeIntent<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetStripeIntentRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetStripeIntentRequest {
    const PATH: &'static str = "/xrpc/app.ocho.payment.getStripeIntent";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetStripeIntent<S>;
    type Response = GetStripeIntentResponse;
}

pub mod get_stripe_intent_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 Amount;
        type Id;
        type Iss;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Amount = Unset;
        type Id = Unset;
        type Iss = Unset;
    }
    ///State transition - sets the `amount` field to Set
    pub struct SetAmount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAmount<St> {}
    impl<St: State> State for SetAmount<St> {
        type Amount = Set<members::amount>;
        type Id = St::Id;
        type Iss = St::Iss;
    }
    ///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 Amount = St::Amount;
        type Id = Set<members::id>;
        type Iss = St::Iss;
    }
    ///State transition - sets the `iss` field to Set
    pub struct SetIss<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIss<St> {}
    impl<St: State> State for SetIss<St> {
        type Amount = St::Amount;
        type Id = St::Id;
        type Iss = Set<members::iss>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `amount` field
        pub struct amount(());
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `iss` field
        pub struct iss(());
    }
}

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

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

impl<S: BosStr> GetStripeIntent<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetStripeIntentBuilder<get_stripe_intent_state::Empty, S> {
        GetStripeIntentBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetStripeIntentBuilder<St, S>
where
    St: get_stripe_intent_state::State,
    St::Amount: get_stripe_intent_state::IsUnset,
{
    /// Set the `amount` field (required)
    pub fn amount(
        mut self,
        value: impl Into<i64>,
    ) -> GetStripeIntentBuilder<get_stripe_intent_state::SetAmount<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetStripeIntentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> GetStripeIntentBuilder<St, S>
where
    St: get_stripe_intent_state::State,
    St::Iss: get_stripe_intent_state::IsUnset,
{
    /// Set the `iss` field (required)
    pub fn iss(
        mut self,
        value: impl Into<Did<S>>,
    ) -> GetStripeIntentBuilder<get_stripe_intent_state::SetIss<St>, S> {
        self._fields.2 = Option::Some(value.into());
        GetStripeIntentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: get_stripe_intent_state::State, S: BosStr> GetStripeIntentBuilder<St, S> {
    /// Set the `token` field (optional)
    pub fn token(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `token` field to an Option value (optional)
    pub fn maybe_token(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> GetStripeIntentBuilder<St, S>
where
    St: get_stripe_intent_state::State,
    St::Amount: get_stripe_intent_state::IsSet,
    St::Id: get_stripe_intent_state::IsSet,
    St::Iss: get_stripe_intent_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetStripeIntent<S> {
        GetStripeIntent {
            amount: self._fields.0.unwrap(),
            id: self._fields.1.unwrap(),
            iss: self._fields.2.unwrap(),
            token: self._fields.3,
        }
    }
}