1use super::types::*;
2use crate::client::{AuthType, Client};
3use crate::error::ApiResult;
4
5pub trait UserApi {
6 fn get_teams(
8 &self,
9 project_key: String,
10 auth: AuthType,
11 ) -> impl std::future::Future<Output = ApiResult<GetTeamsResponse>> + Send;
12
13 fn search_users(
15 &self,
16 request: SearchUsersRequest,
17 auth: AuthType,
18 ) -> impl std::future::Future<Output = ApiResult<serde_json::Value>> + Send;
19
20 fn get_user_detail(
22 &self,
23 request: GetUserDetailRequest,
24 auth: AuthType,
25 ) -> impl std::future::Future<Output = ApiResult<serde_json::Value>> + Send;
26}
27
28impl UserApi for Client {
29 async fn get_teams(&self, project_key: String, auth: AuthType) -> ApiResult<GetTeamsResponse> {
30 Ok(self
31 .get(&format!("{}/teams/all", project_key), auth)
32 .await?)
33 }
34
35 async fn search_users(
36 &self,
37 request: SearchUsersRequest,
38 auth: AuthType,
39 ) -> ApiResult<serde_json::Value> {
40 Ok(self.post("user/search", request, auth).await?)
41 }
42
43 async fn get_user_detail(
44 &self,
45 request: GetUserDetailRequest,
46 auth: AuthType,
47 ) -> ApiResult<serde_json::Value> {
48 Ok(self.post("user/query", request, auth).await?)
49 }
50}