// AUTO-GENERATED by mizan — do not edit

use serde::{Deserialize, Serialize};
use serde_json::Value;

use mizan_rust::{MizanClient, MizanError};

use crate::types::{UserOrdersOutput, UserProfileOutput};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserContextData {
    pub user_orders: UserOrdersOutput,
    pub user_profile: UserProfileOutput,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserContextParams {
    pub user_id: i64,
}

pub async fn fetch_user_context(
    client: &MizanClient,
    params: &UserContextParams,
) -> Result<UserContextData, MizanError> {
    let params_value = serde_json::to_value(params).unwrap_or(Value::Object(Default::default()));
    let raw = client.fetch_context("user", &params_value).await?;
    serde_json::from_value(raw)
        .map_err(|e| MizanError::transport(format!("decode user context: {e}")))
}
