Skip to content

Commit

Permalink
add query params
Browse files Browse the repository at this point in the history
  • Loading branch information
on9au committed Jun 21, 2024
1 parent 84da337 commit 8e9476b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/api/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::{
},
};

use super::user;

impl MarzbanAPIClient {
pub async fn admin_token(
&self,
Expand Down Expand Up @@ -183,11 +185,27 @@ impl MarzbanAPIClient {
}
}

// TODO: Add query params!
pub async fn get_admins(&self) -> Result<Vec<Admin>, ApiError> {
pub async fn get_admins(
&self,
offset: Option<i32>,
limit: Option<i32>,
username: Option<&str>,
) -> Result<Vec<Admin>, ApiError> {
let url = format!("{}/api/admin/", self.base_url);
let mut params = Vec::new();
if let Some(value) = offset {
params.push(value.to_string())
}
if let Some(value) = limit {
params.push(value.to_string())
}
if let Some(value) = username {
params.push(value.to_string())
}

let response = self
.prepare_authorized_request(reqwest::Method::GET, &url)
.query(&params)
.send()
.await?;

Expand Down

0 comments on commit 8e9476b

Please sign in to comment.