//! Auto-generated API client stubs.
//! x-gql API
//! Generated by x-ranger site-docs. Do not edit by hand.

use reqwest::{Client, Error, Response};

#[derive(Clone, Debug)]
pub struct ApiClient {
    pub base_url: String,
    pub http: Client,
}

impl ApiClient {
    pub fn new(base_url: impl Into<String>) -> Self {
        Self {
            base_url: base_url.into().trim_end_matches('/').to_string(),
            http: Client::new(),
        }
    }

    async fn request(&self, method: reqwest::Method, path: &str) -> Result<Response, Error> {
        let url = format!("{}{}", self.base_url, path);
        self.http.request(method, url).send().await
    }

    /// Resolve a knotchain federation record by chain id.
    pub async fn federation_chain(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::GET, "/api/federationChain").await
    }

    /// N1 two-step lookup (route + witness + admissible path proof).
    pub async fn federation_lookup(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::GET, "/api/federationLookup").await
    }

    /// Fetch signed federation index snapshot metadata.
    pub async fn federation_snapshot(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::GET, "/api/federationSnapshot").await
    }

    /// Query: root → read_user
    pub async fn read_user(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::GET, "/api/readUser").await
    }

    /// Mutation fold: input_user → save_user
    pub async fn save_user(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::POST, "/api/saveUser").await
    }

    /// Query: request → scan_result
    pub async fn scan_result(&self) -> Result<Response, Error> {
        self.request(reqwest::Method::GET, "/api/scanResult").await
    }

}
