Skip to main content

nil_client/client/
chat.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use super::Client;
5use crate::error::Result;
6use crate::http;
7use nil_payload::request::chat::*;
8use nil_payload::response::chat::*;
9
10impl Client {
11  pub async fn get_chat_history(
12    &self,
13    req: GetChatHistoryRequest,
14  ) -> Result<GetChatHistoryResponse> {
15    http::json_put("get-chat-history")
16      .body(req)
17      .server(self.server)
18      .maybe_authorization(self.authorization.as_ref())
19      .circuit_breaker(self.circuit_breaker())
20      .retry(&self.retry)
21      .user_agent(&self.user_agent)
22      .send()
23      .await
24  }
25
26  pub async fn push_chat_message(
27    &self,
28    req: PushChatMessageRequest,
29  ) -> Result<PushChatMessageResponse> {
30    http::json_post("push-chat-message")
31      .body(req)
32      .server(self.server)
33      .maybe_authorization(self.authorization.as_ref())
34      .circuit_breaker(self.circuit_breaker())
35      .user_agent(&self.user_agent)
36      .send()
37      .await
38  }
39}