tangled-api 0.1.0

Lexicon-generated XRPC client for Tangled and AT Protocol APIs
Documentation
// @generated by `cargo xtask codegen` — do not edit.
// source: lexicons/com/atproto/server/createSession.json (com.atproto.server.createSession)

#![allow(clippy::all)]

pub const NSID: &str = "com.atproto.server.createSession";

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Input {
    /// When true, instead of throwing error for takendown accounts, a valid response with a narrow scoped token will be returned
    #[serde(
        rename = "allowTakendown",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub allow_takendown: Option<bool>,
    #[serde(
        rename = "authFactorToken",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub auth_factor_token: Option<String>,
    /// Handle or other identifier supported by the server for the authenticating user.
    pub identifier: String,
    pub password: String,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    #[serde(rename = "accessJwt")]
    pub access_jwt: String,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub active: Option<bool>,
    pub did: String,
    #[serde(
        rename = "didDoc",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub did_doc: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub email: Option<String>,
    #[serde(
        rename = "emailAuthFactor",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub email_auth_factor: Option<bool>,
    #[serde(
        rename = "emailConfirmed",
        skip_serializing_if = "Option::is_none",
        default
    )]
    pub email_confirmed: Option<bool>,
    pub handle: String,
    #[serde(rename = "refreshJwt")]
    pub refresh_jwt: String,
    /// 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.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub status: Option<String>,
}

/// Create an authentication session.
///
/// Errors:
/// - `AccountTakedown`
/// - `AuthFactorTokenRequired`
pub fn create_session(
    http: &reqwest::Client,
    base: &str,
    input: &Input,
) -> reqwest::RequestBuilder {
    let rb = http.post(crate::xrpc::xrpc_url(base, NSID));
    let rb = rb.header(reqwest::header::ACCEPT, "application/json");
    let rb = rb.json(input);
    rb
}