#![doc = "Definitions for the `com.atproto.server.createSession` namespace."]
#[doc = "`com.atproto.server.createSession`"]
#[doc = "Create an authentication session."]
#[async_trait::async_trait]
pub trait CreateSession: crate::xrpc::XrpcClient {
async fn create_session(&self, input: Input) -> Result<Output, Box<dyn std::error::Error>> {
let body = crate::xrpc::XrpcClient::send::<Error>(
self,
http::Method::POST,
"com.atproto.server.createSession",
None,
Some(serde_json::to_vec(&input)?),
Some(String::from("application/json")),
)
.await?;
serde_json::from_slice(&body).map_err(|e| e.into())
}
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Input {
#[doc = "Handle or other identifier supported by the server for the authenticating user."]
pub identifier: String,
pub password: String,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Output {
pub access_jwt: String,
pub did: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
pub handle: String,
pub refresh_jwt: String,
}
#[derive(serde :: Serialize, serde :: Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "error", content = "message")]
pub enum Error {
AccountTakedown(Option<String>),
}