Skip to main content

openapp_sdk_core/resources/
scripting.rs

1//! `OpenApp` Scripting resource group.
2
3use 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 ScriptingClient {
15    transport: Arc<Transport>,
16}
17
18impl ScriptingClient {
19    pub(crate) fn new(transport: Arc<Transport>) -> Self {
20        Self { transport }
21    }
22
23    /// `POST /scripting/execute` — run an `OpenApp` Scripting program.
24    pub async fn execute(&self, body: &JsonValue) -> Result<JsonValue, SdkError> {
25        self.transport
26            .request_json::<JsonValue, JsonValue>(RequestSpec {
27                method: Method::POST,
28                path: "/scripting/execute",
29                body: Some(body),
30                ..Default::default()
31            })
32            .await
33    }
34}