gitea_sdk/api/users/
orgs.rs

1use build_it::Builder;
2use serde::Serialize;
3
4use crate::{model::orgs::Organization, Client};
5
6#[derive(Debug, Default, Builder, Serialize)]
7#[build_it(into)]
8pub struct Orgs {
9    #[serde(skip)]
10    #[build_it(skip)]
11    username: String,
12    page: Option<i64>,
13    limit: Option<i64>,
14}
15
16impl Orgs {
17    pub fn new(username: impl ToString) -> Self {
18        Self {
19            page: None,
20            limit: None,
21            username: username.to_string(),
22        }
23    }
24    /// Send the request to get the user's organizations.
25    pub async fn send(&self, client: &Client) -> crate::Result<Vec<Organization>> {
26        let username = &self.username;
27        let req = client
28            .get(format!("users/{username}/orgs"))
29            .query(self)
30            .build()?;
31        let res = client.make_request(req).await?;
32        client.parse_response(res).await
33    }
34}