use super::{CharacterLocation, CharacterOnline, CharacterShip};
use crate::{get_authenticated, Esi, EsiResult, Response};

impl Esi {
  /**
   * Requires the following scope: esi-location.read_location.v1
   * Information about the characters current location. Returns the current solar system id, and also the current station or structure ID if applicable
   * esi: https://esi.evetech.net/latest/characters/{character_id}/location/
   */
  pub async fn get_character_location(
    &self,
    access_token: &str,
    character_id: i32,
    etag: Option<&str>,
  ) -> EsiResult<Response<CharacterLocation>> {
    let result = get_authenticated::<CharacterLocation>(
      access_token,
      &format!("characters/{}/location", character_id),
      self,
      None,
      etag,
    )
    .await?;
    Ok(result)
  }

  /**
   * Requires the following scope: esi-location.read_online.v1
   * Checks if the character is currently online
   * esi: https://esi.evetech.net/latest/characters/{character_id}/online/
   */
  pub async fn get_character_online(
    &self,
    access_token: &str,
    character_id: i32,
    etag: Option<&str>,
  ) -> EsiResult<Response<CharacterOnline>> {
    let result = get_authenticated::<CharacterOnline>(
      access_token,
      &format!("characters/{}/online", character_id),
      self,
      None,
      etag,
    )
    .await?;
    Ok(result)
  }

  /**
   * Requires the following scope: esi-location.read_ship_type.v1
   * Get the current ship type, name and id
   * esi: https://esi.evetech.net/latest/characters/{character_id}/ship/
   */
  pub async fn get_character_ship(
    &self,
    access_token: &str,
    character_id: i32,
    etag: Option<&str>,
  ) -> EsiResult<Response<CharacterShip>> {
    let result = get_authenticated::<CharacterShip>(
      access_token,
      &format!("characters/{}/ship", character_id),
      self,
      None,
      etag,
    )
    .await?;
    Ok(result)
  }
}
