gitea_sdk/api/users/
orgs.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use build_it::Builder;
use serde::Serialize;

use crate::{model::orgs::Organization, Client};

#[derive(Debug, Default, Builder, Serialize)]
#[build_it(into)]
pub struct Orgs {
    #[serde(skip)]
    #[build_it(skip)]
    username: String,
    page: Option<i64>,
    limit: Option<i64>,
}

impl Orgs {
    pub fn new(username: impl ToString) -> Self {
        Self {
            page: None,
            limit: None,
            username: username.to_string(),
        }
    }
    /// Send the request to get the user's organizations.
    pub async fn send(&self, client: &Client) -> crate::Result<Vec<Organization>> {
        let username = &self.username;
        let req = client
            .get(format!("users/{username}/orgs"))
            .query(self)
            .build()?;
        let res = client.make_request(req).await?;
        client.parse_response(res).await
    }
}