// Copyright (C) Call of Nil contributors
// SPDX-License-Identifier: AGPL-3.0-only

use crate::client::Client;
use crate::error::Result;
use crate::http;
use nil_payload::request::npc::precursor::*;
use nil_payload::response::npc::precursor::*;

impl Client {
  pub async fn get_precursor_coords(
    &self,
    req: GetPrecursorCoordsRequest,
  ) -> Result<GetPrecursorCoordsResponse> {
    http::json_put("get-precursor-coords")
      .body(req)
      .server(self.server)
      .circuit_breaker(self.circuit_breaker())
      .retry(&self.retry)
      .user_agent(&self.user_agent)
      .send()
      .await
  }

  pub async fn get_public_precursor(
    &self,
    req: GetPublicPrecursorRequest,
  ) -> Result<GetPublicPrecursorResponse> {
    http::json_put("get-public-precursor")
      .body(req)
      .server(self.server)
      .circuit_breaker(self.circuit_breaker())
      .retry(&self.retry)
      .user_agent(&self.user_agent)
      .send()
      .await
  }

  pub async fn get_public_precursors(
    &self,
    req: GetPublicPrecursorsRequest,
  ) -> Result<GetPublicPrecursorsResponse> {
    http::json_put("get-public-precursors")
      .body(req)
      .server(self.server)
      .circuit_breaker(self.circuit_breaker())
      .retry(&self.retry)
      .user_agent(&self.user_agent)
      .send()
      .await
  }
}
