openapp_sdk_core/resources/
me.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 MeClient {
15 transport: Arc<Transport>,
16}
17
18impl MeClient {
19 pub(crate) fn new(transport: Arc<Transport>) -> Self {
20 Self { transport }
21 }
22
23 pub async fn apartments(&self) -> Result<Vec<JsonValue>, SdkError> {
24 self.transport
25 .request_json::<(), Vec<JsonValue>>(RequestSpec {
26 method: Method::GET,
27 path: "/me/apartments",
28 ..Default::default()
29 })
30 .await
31 }
32
33 pub async fn invitations(&self) -> Result<Vec<JsonValue>, SdkError> {
34 self.transport
35 .request_json::<(), Vec<JsonValue>>(RequestSpec {
36 method: Method::GET,
37 path: "/me/invitations",
38 ..Default::default()
39 })
40 .await
41 }
42
43 pub async fn push_subscription_status(&self) -> Result<JsonValue, SdkError> {
44 self.transport
45 .request_json::<(), JsonValue>(RequestSpec {
46 method: Method::GET,
47 path: "/me/push-subscription-status",
48 ..Default::default()
49 })
50 .await
51 }
52
53 pub async fn push_vapid_public_key(&self) -> Result<JsonValue, SdkError> {
54 self.transport
55 .request_json::<(), JsonValue>(RequestSpec {
56 method: Method::GET,
57 path: "/me/push-vapid-public-key",
58 ..Default::default()
59 })
60 .await
61 }
62
63 pub async fn subscribe_push(&self, body: &JsonValue) -> Result<JsonValue, SdkError> {
64 self.transport
65 .request_json::<JsonValue, JsonValue>(RequestSpec {
66 method: Method::POST,
67 path: "/me/push-subscriptions",
68 body: Some(body),
69 ..Default::default()
70 })
71 .await
72 }
73}