openapp_sdk_core/resources/
me.rs1use std::sync::Arc;
4
5use reqwest::Method;
6
7use super::types;
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 profile(&self) -> Result<types::MeProfileResponse, SdkError> {
24 self.transport
25 .request_json::<(), types::MeProfileResponse>(RequestSpec {
26 method: Method::GET,
27 path: "/me/profile",
28 ..Default::default()
29 })
30 .await
31 }
32
33 pub async fn directory_listings(&self) -> Result<types::MeListingsResponse, SdkError> {
34 self.transport
35 .request_json::<(), types::MeListingsResponse>(RequestSpec {
36 method: Method::GET,
37 path: "/me/directory-listings",
38 ..Default::default()
39 })
40 .await
41 }
42
43 pub async fn invitations(&self) -> Result<types::MeInvitationsResponse, SdkError> {
44 self.transport
45 .request_json::<(), types::MeInvitationsResponse>(RequestSpec {
46 method: Method::GET,
47 path: "/me/invitations",
48 ..Default::default()
49 })
50 .await
51 }
52
53 pub async fn push_subscription_status(
54 &self,
55 ) -> Result<types::MePushSubscriptionStatusResponse, SdkError> {
56 self.transport
57 .request_json::<(), types::MePushSubscriptionStatusResponse>(RequestSpec {
58 method: Method::GET,
59 path: "/me/push-subscription-status",
60 ..Default::default()
61 })
62 .await
63 }
64
65 pub async fn push_vapid_public_key(
66 &self,
67 ) -> Result<types::MePushVapidPublicKeyResponse, SdkError> {
68 self.transport
69 .request_json::<(), types::MePushVapidPublicKeyResponse>(RequestSpec {
70 method: Method::GET,
71 path: "/me/push-vapid-public-key",
72 ..Default::default()
73 })
74 .await
75 }
76
77 pub async fn subscribe_push(
78 &self,
79 body: &types::PostMePushSubscriptionPayload,
80 ) -> Result<(), SdkError> {
81 self.transport
82 .request_json::<types::PostMePushSubscriptionPayload, ()>(RequestSpec {
83 method: Method::POST,
84 path: "/me/push-subscriptions",
85 body: Some(body),
86 ..Default::default()
87 })
88 .await
89 }
90}