Skip to main content

unifly_api/integration/client/
clients.rs

1use serde::Serialize;
2use uuid::Uuid;
3
4use super::{Error, IntegrationClient, types};
5
6impl IntegrationClient {
7    // ── Clients ──────────────────────────────────────────────────────
8
9    pub async fn list_clients(
10        &self,
11        site_id: &Uuid,
12        offset: i64,
13        limit: i32,
14    ) -> Result<types::Page<types::ClientResponse>, Error> {
15        self.get_with_params(
16            &format!("v1/sites/{site_id}/clients"),
17            &[("offset", offset.to_string()), ("limit", limit.to_string())],
18        )
19        .await
20    }
21
22    pub async fn get_client(
23        &self,
24        site_id: &Uuid,
25        client_id: &Uuid,
26    ) -> Result<types::ClientDetailsResponse, Error> {
27        self.get(&format!("v1/sites/{site_id}/clients/{client_id}"))
28            .await
29    }
30
31    pub async fn client_action(
32        &self,
33        site_id: &Uuid,
34        client_id: &Uuid,
35        action: &str,
36    ) -> Result<types::ClientActionResponse, Error> {
37        #[derive(Serialize)]
38        struct Body<'a> {
39            action: &'a str,
40        }
41
42        self.post(
43            &format!("v1/sites/{site_id}/clients/{client_id}/actions"),
44            &Body { action },
45        )
46        .await
47    }
48}