mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-19 18:49:20 +01:00
implement meta api in client
This commit is contained in:
parent
609f2bd001
commit
f5b4c6211b
@ -5,6 +5,7 @@ use bank_core::{
|
||||
ApiError, NameOrUuid, TokenResponse,
|
||||
account::{Account, UserAccountInfo},
|
||||
chat::{Chat, ChatInfo, ChatMessage, SendMessage, StartChat},
|
||||
meta::{Bank, Motd},
|
||||
pagination::{Pagination, RequestPagination},
|
||||
transaction::{Direction, Transaction},
|
||||
user::{User, UserAccounts, UserBalance},
|
||||
@ -162,10 +163,6 @@ pub async fn handle_response<T: DeserializeOwned>(
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UsersApi<'a> {
|
||||
api: &'a ApiClient,
|
||||
}
|
||||
|
||||
macro_rules! request {
|
||||
($api:expr, $method:ident, $path:expr) => {{
|
||||
let api = &$api;
|
||||
@ -173,6 +170,28 @@ macro_rules! request {
|
||||
}};
|
||||
}
|
||||
|
||||
pub struct MetaApi<'a> {
|
||||
api: &'a ApiClient,
|
||||
}
|
||||
|
||||
impl MetaApi<'_> {
|
||||
pub async fn motd(&self) -> Result<Motd, ClientError> {
|
||||
let response = request!(self.api, get, "/api/meta/motd").send().await?;
|
||||
let body = handle_response(response).await?;
|
||||
Ok(body)
|
||||
}
|
||||
|
||||
pub async fn bank(&self) -> Result<Bank, ClientError> {
|
||||
let response = request!(self.api, get, "/api/meta/bank").send().await?;
|
||||
let body = handle_response(response).await?;
|
||||
Ok(body)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UsersApi<'a> {
|
||||
api: &'a ApiClient,
|
||||
}
|
||||
|
||||
impl UsersApi<'_> {
|
||||
pub async fn list(&self, limit: u64, offset: u64) -> Result<Pagination<User>, ClientError> {
|
||||
let response = request!(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user