// 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::infrastructure::academy::*;
use nil_payload::response::infrastructure::academy::*;

impl Client {
  pub async fn add_academy_recruit_order(&self, req: AddAcademyRecruitOrderRequest) -> Result<()> {
    http::post("add-academy-recruit-order")
      .body(req)
      .server(self.server)
      .maybe_authorization(self.authorization.as_ref())
      .circuit_breaker(self.circuit_breaker())
      .user_agent(&self.user_agent)
      .send()
      .await
  }

  pub async fn cancel_academy_recruit_order(
    &self,
    req: CancelAcademyRecruitOrderRequest,
  ) -> Result<()> {
    http::post("cancel-academy-recruit-order")
      .body(req)
      .server(self.server)
      .maybe_authorization(self.authorization.as_ref())
      .circuit_breaker(self.circuit_breaker())
      .user_agent(&self.user_agent)
      .send()
      .await
  }

  pub async fn get_academy_recruit_catalog(
    &self,
    req: GetAcademyRecruitCatalogRequest,
  ) -> Result<GetAcademyRecruitCatalogResponse> {
    http::json_put("get-academy-recruit-catalog")
      .body(req)
      .server(self.server)
      .maybe_authorization(self.authorization.as_ref())
      .circuit_breaker(self.circuit_breaker())
      .retry(&self.retry)
      .user_agent(&self.user_agent)
      .send()
      .await
  }
}
