openapp_sdk_core/resources/
apartment_residents.rs1use std::sync::Arc;
4
5use reqwest::Method;
6
7use super::JsonValue;
8use crate::{
9 error::SdkError,
10 transport::{RequestSpec, Transport},
11};
12
13#[derive(Debug, Clone)]
14pub struct ApartmentResidentsClient {
15 transport: Arc<Transport>,
16}
17
18impl ApartmentResidentsClient {
19 pub(crate) fn new(transport: Arc<Transport>) -> Self {
20 Self { transport }
21 }
22
23 pub async fn list(&self, integration_id: &str) -> Result<Vec<JsonValue>, SdkError> {
24 let path = format!("/integrations/{integration_id}/building-users");
25 self.transport
26 .request_json::<(), Vec<JsonValue>>(RequestSpec {
27 method: Method::GET,
28 path: &path,
29 ..Default::default()
30 })
31 .await
32 }
33
34 pub async fn add(&self, integration_id: &str, body: &JsonValue) -> Result<JsonValue, SdkError> {
35 let path = format!("/integrations/{integration_id}/building-users");
36 self.transport
37 .request_json::<JsonValue, JsonValue>(RequestSpec {
38 method: Method::POST,
39 path: &path,
40 body: Some(body),
41 ..Default::default()
42 })
43 .await
44 }
45
46 pub async fn remove(&self, integration_id: &str, user_id: &str) -> Result<(), SdkError> {
47 let path = format!("/integrations/{integration_id}/building-users/{user_id}");
48 self.transport
49 .request_json::<(), ()>(RequestSpec {
50 method: Method::DELETE,
51 path: &path,
52 ..Default::default()
53 })
54 .await
55 }
56}