1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.createSession
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10 serde::Serialize,
11 serde::Deserialize,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 jacquard_derive::IntoStatic,
17 Default
18)]
19#[serde(rename_all = "camelCase")]
20pub struct CreateSession<'a> {
21 /// When true, instead of throwing error for takendown accounts, a valid response with a narrow scoped token will be returned
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 pub allow_takendown: std::option::Option<bool>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 #[serde(borrow)]
26 pub auth_factor_token: std::option::Option<jacquard_common::CowStr<'a>>,
27 /// Handle or other identifier supported by the server for the authenticating user.
28 #[serde(borrow)]
29 pub identifier: jacquard_common::CowStr<'a>,
30 #[serde(borrow)]
31 pub password: jacquard_common::CowStr<'a>,
32}
33
34#[jacquard_derive::lexicon]
35#[derive(
36 serde::Serialize,
37 serde::Deserialize,
38 Debug,
39 Clone,
40 PartialEq,
41 Eq,
42 jacquard_derive::IntoStatic
43)]
44#[serde(rename_all = "camelCase")]
45pub struct CreateSessionOutput<'a> {
46 #[serde(borrow)]
47 pub access_jwt: jacquard_common::CowStr<'a>,
48 #[serde(skip_serializing_if = "std::option::Option::is_none")]
49 pub active: std::option::Option<bool>,
50 #[serde(borrow)]
51 pub did: jacquard_common::types::string::Did<'a>,
52 #[serde(skip_serializing_if = "std::option::Option::is_none")]
53 #[serde(borrow)]
54 pub did_doc: std::option::Option<jacquard_common::types::value::Data<'a>>,
55 #[serde(skip_serializing_if = "std::option::Option::is_none")]
56 #[serde(borrow)]
57 pub email: std::option::Option<jacquard_common::CowStr<'a>>,
58 #[serde(skip_serializing_if = "std::option::Option::is_none")]
59 pub email_auth_factor: std::option::Option<bool>,
60 #[serde(skip_serializing_if = "std::option::Option::is_none")]
61 pub email_confirmed: std::option::Option<bool>,
62 #[serde(borrow)]
63 pub handle: jacquard_common::types::string::Handle<'a>,
64 #[serde(borrow)]
65 pub refresh_jwt: jacquard_common::CowStr<'a>,
66 /// If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.
67 #[serde(skip_serializing_if = "std::option::Option::is_none")]
68 #[serde(borrow)]
69 pub status: std::option::Option<jacquard_common::CowStr<'a>>,
70}
71
72#[jacquard_derive::open_union]
73#[derive(
74 serde::Serialize,
75 serde::Deserialize,
76 Debug,
77 Clone,
78 PartialEq,
79 Eq,
80 thiserror::Error,
81 miette::Diagnostic,
82 jacquard_derive::IntoStatic
83)]
84#[serde(tag = "error", content = "message")]
85#[serde(bound(deserialize = "'de: 'a"))]
86pub enum CreateSessionError<'a> {
87 #[serde(rename = "AccountTakedown")]
88 AccountTakedown(std::option::Option<String>),
89 #[serde(rename = "AuthFactorTokenRequired")]
90 AuthFactorTokenRequired(std::option::Option<String>),
91}
92
93impl std::fmt::Display for CreateSessionError<'_> {
94 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
95 match self {
96 Self::AccountTakedown(msg) => {
97 write!(f, "AccountTakedown")?;
98 if let Some(msg) = msg {
99 write!(f, ": {}", msg)?;
100 }
101 Ok(())
102 }
103 Self::AuthFactorTokenRequired(msg) => {
104 write!(f, "AuthFactorTokenRequired")?;
105 if let Some(msg) = msg {
106 write!(f, ": {}", msg)?;
107 }
108 Ok(())
109 }
110 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
111 }
112 }
113}
114
115///Response type for
116///com.atproto.server.createSession
117pub struct CreateSessionResponse;
118impl jacquard_common::xrpc::XrpcResp for CreateSessionResponse {
119 const NSID: &'static str = "com.atproto.server.createSession";
120 const ENCODING: &'static str = "application/json";
121 type Output<'de> = CreateSessionOutput<'de>;
122 type Err<'de> = CreateSessionError<'de>;
123}
124
125impl<'a> jacquard_common::xrpc::XrpcRequest for CreateSession<'a> {
126 const NSID: &'static str = "com.atproto.server.createSession";
127 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
128 "application/json",
129 );
130 type Response = CreateSessionResponse;
131}
132
133///Endpoint type for
134///com.atproto.server.createSession
135pub struct CreateSessionRequest;
136impl jacquard_common::xrpc::XrpcEndpoint for CreateSessionRequest {
137 const PATH: &'static str = "/xrpc/com.atproto.server.createSession";
138 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
139 "application/json",
140 );
141 type Request<'de> = CreateSession<'de>;
142 type Response = CreateSessionResponse;
143}