Skip to main content

nil_client/client/npc/
bot.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::client::Client;
5use crate::error::Result;
6use crate::http;
7use nil_core::continent::Coord;
8use nil_core::npc::bot::PublicBot;
9use nil_payload::npc::bot::*;
10
11impl Client {
12  pub async fn get_bot_coords(&self, req: GetBotCoordsRequest) -> Result<Vec<Coord>> {
13    http::json_put("get-bot-coords")
14      .body(req)
15      .server(self.server)
16      .circuit_breaker(self.circuit_breaker())
17      .retry(&self.retry)
18      .user_agent(&self.user_agent)
19      .send()
20      .await
21  }
22
23  pub async fn get_public_bot(&self, req: GetPublicBotRequest) -> Result<PublicBot> {
24    http::json_put("get-public-bot")
25      .body(req)
26      .server(self.server)
27      .circuit_breaker(self.circuit_breaker())
28      .retry(&self.retry)
29      .user_agent(&self.user_agent)
30      .send()
31      .await
32  }
33
34  pub async fn get_public_bots(&self, req: GetPublicBotsRequest) -> Result<Vec<PublicBot>> {
35    http::json_put("get-public-bots")
36      .body(req)
37      .server(self.server)
38      .circuit_breaker(self.circuit_breaker())
39      .retry(&self.retry)
40      .user_agent(&self.user_agent)
41      .send()
42      .await
43  }
44}