openapp_sdk_core/resources/
public_access.rs1use std::sync::Arc;
8
9use reqwest::Method;
10
11use super::JsonValue;
12use crate::{
13 error::SdkError,
14 transport::{RequestSpec, Transport},
15};
16
17#[derive(Debug, Clone)]
18pub struct PublicAccessClient {
19 transport: Arc<Transport>,
20}
21
22impl PublicAccessClient {
23 pub(crate) fn new(transport: Arc<Transport>) -> Self {
24 Self { transport }
25 }
26
27 pub async fn get_invite(&self, invite_token: &str) -> Result<JsonValue, SdkError> {
30 let path = format!("/public/access/invites/{invite_token}");
31 self.transport
32 .request_json::<(), JsonValue>(RequestSpec {
33 method: Method::GET,
34 path: &path,
35 ..Default::default()
36 })
37 .await
38 }
39
40 pub async fn claim_invite(
41 &self,
42 invite_token: &str,
43 body: &JsonValue,
44 ) -> Result<JsonValue, SdkError> {
45 let path = format!("/public/access/invites/{invite_token}/claim");
46 self.transport
47 .request_json::<JsonValue, JsonValue>(RequestSpec {
48 method: Method::POST,
49 path: &path,
50 body: Some(body),
51 ..Default::default()
52 })
53 .await
54 }
55
56 pub async fn execute_invite(
57 &self,
58 invite_token: &str,
59 body: &JsonValue,
60 ) -> Result<JsonValue, SdkError> {
61 let path = format!("/public/access/invites/{invite_token}/execute");
62 self.transport
63 .request_json::<JsonValue, JsonValue>(RequestSpec {
64 method: Method::POST,
65 path: &path,
66 body: Some(body),
67 ..Default::default()
68 })
69 .await
70 }
71
72 pub async fn start_invite_session(
73 &self,
74 invite_token: &str,
75 body: &JsonValue,
76 ) -> Result<JsonValue, SdkError> {
77 let path = format!("/public/access/invites/{invite_token}/session");
78 self.transport
79 .request_json::<JsonValue, JsonValue>(RequestSpec {
80 method: Method::POST,
81 path: &path,
82 body: Some(body),
83 ..Default::default()
84 })
85 .await
86 }
87
88 pub async fn get_portal(&self, public_portal_id: &str) -> Result<JsonValue, SdkError> {
91 let path = format!("/public/access/portals/{public_portal_id}");
92 self.transport
93 .request_json::<(), JsonValue>(RequestSpec {
94 method: Method::GET,
95 path: &path,
96 ..Default::default()
97 })
98 .await
99 }
100
101 pub async fn portal_lights(
102 &self,
103 public_portal_id: &str,
104 body: &JsonValue,
105 ) -> Result<JsonValue, SdkError> {
106 let path = format!("/public/access/portals/{public_portal_id}/lights");
107 self.transport
108 .request_json::<JsonValue, JsonValue>(RequestSpec {
109 method: Method::POST,
110 path: &path,
111 body: Some(body),
112 ..Default::default()
113 })
114 .await
115 }
116
117 pub async fn portal_open(
118 &self,
119 public_portal_id: &str,
120 body: &JsonValue,
121 ) -> Result<JsonValue, SdkError> {
122 let path = format!("/public/access/portals/{public_portal_id}/open");
123 self.transport
124 .request_json::<JsonValue, JsonValue>(RequestSpec {
125 method: Method::POST,
126 path: &path,
127 body: Some(body),
128 ..Default::default()
129 })
130 .await
131 }
132
133 pub async fn portal_reachable(&self, public_portal_id: &str) -> Result<JsonValue, SdkError> {
134 let path = format!("/public/access/portals/{public_portal_id}/reachable");
135 self.transport
136 .request_json::<(), JsonValue>(RequestSpec {
137 method: Method::GET,
138 path: &path,
139 ..Default::default()
140 })
141 .await
142 }
143
144 pub async fn portal_start_session(
145 &self,
146 public_portal_id: &str,
147 body: &JsonValue,
148 ) -> Result<JsonValue, SdkError> {
149 let path = format!("/public/access/portals/{public_portal_id}/sessions");
150 self.transport
151 .request_json::<JsonValue, JsonValue>(RequestSpec {
152 method: Method::POST,
153 path: &path,
154 body: Some(body),
155 ..Default::default()
156 })
157 .await
158 }
159
160 pub async fn portal_targets(&self, public_portal_id: &str) -> Result<JsonValue, SdkError> {
161 let path = format!("/public/access/portals/{public_portal_id}/targets");
162 self.transport
163 .request_json::<(), JsonValue>(RequestSpec {
164 method: Method::GET,
165 path: &path,
166 ..Default::default()
167 })
168 .await
169 }
170
171 pub async fn get_session(&self, session_id: &str) -> Result<JsonValue, SdkError> {
174 let path = format!("/public/access/sessions/{session_id}");
175 self.transport
176 .request_json::<(), JsonValue>(RequestSpec {
177 method: Method::GET,
178 path: &path,
179 ..Default::default()
180 })
181 .await
182 }
183
184 pub async fn cancel_session(&self, session_id: &str) -> Result<JsonValue, SdkError> {
185 let path = format!("/public/access/sessions/{session_id}/cancel");
186 self.transport
187 .request_json::<(), JsonValue>(RequestSpec {
188 method: Method::POST,
189 path: &path,
190 ..Default::default()
191 })
192 .await
193 }
194
195 pub async fn decline_session(&self, session_id: &str) -> Result<JsonValue, SdkError> {
196 let path = format!("/public/access/sessions/{session_id}/decline");
197 self.transport
198 .request_json::<(), JsonValue>(RequestSpec {
199 method: Method::POST,
200 path: &path,
201 ..Default::default()
202 })
203 .await
204 }
205
206 pub async fn session_lights(
207 &self,
208 session_id: &str,
209 body: &JsonValue,
210 ) -> Result<JsonValue, SdkError> {
211 let path = format!("/public/access/sessions/{session_id}/lights");
212 self.transport
213 .request_json::<JsonValue, JsonValue>(RequestSpec {
214 method: Method::POST,
215 path: &path,
216 body: Some(body),
217 ..Default::default()
218 })
219 .await
220 }
221
222 pub async fn session_notify_message(
223 &self,
224 session_id: &str,
225 body: &JsonValue,
226 ) -> Result<JsonValue, SdkError> {
227 let path = format!("/public/access/sessions/{session_id}/notify-message");
228 self.transport
229 .request_json::<JsonValue, JsonValue>(RequestSpec {
230 method: Method::POST,
231 path: &path,
232 body: Some(body),
233 ..Default::default()
234 })
235 .await
236 }
237
238 pub async fn session_open(
239 &self,
240 session_id: &str,
241 body: &JsonValue,
242 ) -> Result<JsonValue, SdkError> {
243 let path = format!("/public/access/sessions/{session_id}/open");
244 self.transport
245 .request_json::<JsonValue, JsonValue>(RequestSpec {
246 method: Method::POST,
247 path: &path,
248 body: Some(body),
249 ..Default::default()
250 })
251 .await
252 }
253
254 pub async fn session_streams(&self, session_id: &str) -> Result<JsonValue, SdkError> {
255 let path = format!("/public/access/sessions/{session_id}/streams");
256 self.transport
257 .request_json::<(), JsonValue>(RequestSpec {
258 method: Method::GET,
259 path: &path,
260 ..Default::default()
261 })
262 .await
263 }
264}