#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetStripeIntent<'a> {
pub amount: i64,
#[serde(borrow)]
pub id: CowStr<'a>,
#[serde(borrow)]
pub iss: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub token: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetStripeIntentOutput<'a> {
#[serde(borrow)]
pub customer: CowStr<'a>,
#[serde(borrow)]
pub customer_session: CowStr<'a>,
#[serde(borrow)]
pub ephemeral_key: CowStr<'a>,
#[serde(borrow)]
pub payment_intent: CowStr<'a>,
#[serde(borrow)]
pub publishable_key: CowStr<'a>,
}
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<'de> = GetStripeIntentOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetStripeIntent<'a> {
const NSID: &'static str = "app.ocho.payment.getStripeIntent";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetStripeIntentResponse;
}
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<'de> = GetStripeIntent<'de>;
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 {}
}
pub trait State: sealed::Sealed {
type Id;
type Amount;
type Iss;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Amount = Unset;
type Iss = Unset;
}
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 Id = Set<members::id>;
type Amount = S::Amount;
type Iss = S::Iss;
}
pub struct SetAmount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAmount<S> {}
impl<S: State> State for SetAmount<S> {
type Id = S::Id;
type Amount = Set<members::amount>;
type Iss = S::Iss;
}
pub struct SetIss<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIss<S> {}
impl<S: State> State for SetIss<S> {
type Id = S::Id;
type Amount = S::Amount;
type Iss = Set<members::iss>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct amount(());
pub struct iss(());
}
}
pub struct GetStripeIntentBuilder<'a, S: get_stripe_intent_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<CowStr<'a>>, Option<Did<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetStripeIntent<'a> {
pub fn new() -> GetStripeIntentBuilder<'a, get_stripe_intent_state::Empty> {
GetStripeIntentBuilder::new()
}
}
impl<'a> GetStripeIntentBuilder<'a, get_stripe_intent_state::Empty> {
pub fn new() -> Self {
GetStripeIntentBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetStripeIntentBuilder<'a, S>
where
S: get_stripe_intent_state::State,
S::Amount: get_stripe_intent_state::IsUnset,
{
pub fn amount(
mut self,
value: impl Into<i64>,
) -> GetStripeIntentBuilder<'a, get_stripe_intent_state::SetAmount<S>> {
self._fields.0 = Option::Some(value.into());
GetStripeIntentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetStripeIntentBuilder<'a, S>
where
S: get_stripe_intent_state::State,
S::Id: get_stripe_intent_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<CowStr<'a>>,
) -> GetStripeIntentBuilder<'a, get_stripe_intent_state::SetId<S>> {
self._fields.1 = Option::Some(value.into());
GetStripeIntentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetStripeIntentBuilder<'a, S>
where
S: get_stripe_intent_state::State,
S::Iss: get_stripe_intent_state::IsUnset,
{
pub fn iss(
mut self,
value: impl Into<Did<'a>>,
) -> GetStripeIntentBuilder<'a, get_stripe_intent_state::SetIss<S>> {
self._fields.2 = Option::Some(value.into());
GetStripeIntentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_stripe_intent_state::State> GetStripeIntentBuilder<'a, S> {
pub fn token(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_token(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> GetStripeIntentBuilder<'a, S>
where
S: get_stripe_intent_state::State,
S::Id: get_stripe_intent_state::IsSet,
S::Amount: get_stripe_intent_state::IsSet,
S::Iss: get_stripe_intent_state::IsSet,
{
pub fn build(self) -> GetStripeIntent<'a> {
GetStripeIntent {
amount: self._fields.0.unwrap(),
id: self._fields.1.unwrap(),
iss: self._fields.2.unwrap(),
token: self._fields.3,
}
}
}