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

impl Client {
  pub async fn add_prefecture_build_order(
    &self,
    req: AddPrefectureBuildOrderRequest,
  ) -> Result<()> {
    http::post("add-prefecture-build-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_prefecture_build_order(
    &self,
    req: CancelPrefectureBuildOrderRequest,
  ) -> Result<()> {
    http::post("cancel-prefecture-build-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_prefecture_build_catalog(
    &self,
    req: GetPrefectureBuildCatalogRequest,
  ) -> Result<GetPrefectureBuildCatalogResponse> {
    http::json_put("get-prefecture-build-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
  }
}
