//! `mission_client` — REST client for the `missions` API.
//!
//! Real implementation lands in:
//! - AZ-644 `mission_client_pull_and_schema`
//! - AZ-645 `mission_client_waypoint_post`
//! - AZ-646 `mission_client_mapobjects_pull`
//! - AZ-647 `mission_client_mapobjects_push`

use shared::error::{AutopilotError, Result};
use shared::health::ComponentHealth;
use shared::models::mapobject::MapObjectsBundle;
use shared::models::mission::{Coordinate, MissionItem};

const NAME: &str = "mission_client";

#[derive(Debug, Clone)]
pub struct MissionClient {
    pub endpoint: String,
}

impl MissionClient {
    pub fn new(endpoint: String) -> Self {
        Self { endpoint }
    }

    pub fn handle(&self) -> MissionClientHandle {
        MissionClientHandle {
            endpoint: self.endpoint.clone(),
        }
    }
}

#[derive(Debug, Clone)]
pub struct MissionClientHandle {
    #[allow(dead_code)]
    endpoint: String,
}

impl MissionClientHandle {
    pub async fn pull_mission(&self, _mission_id: &str) -> Result<Vec<MissionItem>> {
        Err(AutopilotError::NotImplemented(
            "mission_client::pull_mission (AZ-644)",
        ))
    }

    pub async fn post_middle_waypoint(&self, _mission_id: &str, _at: Coordinate) -> Result<()> {
        Err(AutopilotError::NotImplemented(
            "mission_client::post_middle_waypoint (AZ-645)",
        ))
    }

    pub async fn pull_mapobjects(&self, _mission_id: &str) -> Result<MapObjectsBundle> {
        Err(AutopilotError::NotImplemented(
            "mission_client::pull_mapobjects (AZ-646)",
        ))
    }

    pub async fn push_mapobjects(&self, _bundle: MapObjectsBundle) -> Result<()> {
        Err(AutopilotError::NotImplemented(
            "mission_client::push_mapobjects (AZ-647)",
        ))
    }

    pub fn health(&self) -> ComponentHealth {
        ComponentHealth::disabled(NAME)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_compiles() {
        let h = MissionClient::new("http://127.0.0.1:8443".into()).handle();
        assert_eq!(h.health().level, shared::health::HealthLevel::Disabled);
    }
}
