moodle_api/tool/mobile/
get_config.rs

1use serde::{self, Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug)]
4pub struct Params {
5    /// Settings section name.
6    #[serde(rename = "section")]
7    pub r#section: Option<String>,
8}
9
10#[derive(Serialize, Deserialize, Debug)]
11pub struct ReturnsSettingsItem {
12    /// The name of the setting
13    #[serde(rename = "name")]
14    pub r#name: Option<String>,
15    /// The value of the setting
16    #[serde(rename = "value")]
17    pub r#value: Option<String>,
18}
19
20/// Settings
21pub type r#ReturnsSettings = Vec<ReturnsSettingsItem>;
22
23/// warning
24#[derive(Serialize, Deserialize, Debug)]
25pub struct ReturnsWarningsItem {
26    /// item
27    #[serde(rename = "item")]
28    pub r#item: Option<String>,
29    /// item id
30    #[serde(rename = "itemid")]
31    pub r#itemid: Option<i64>,
32    /// the warning code can be used by the client app to implement specific behaviour
33    #[serde(rename = "warningcode")]
34    pub r#warningcode: Option<String>,
35    /// untranslated english message to explain the warning
36    #[serde(rename = "message")]
37    pub r#message: Option<String>,
38}
39
40/// list of warnings
41pub type r#ReturnsWarnings = Vec<ReturnsWarningsItem>;
42
43#[derive(Serialize, Deserialize, Debug)]
44pub struct Returns {
45    /// Settings
46    #[serde(rename = "settings")]
47    pub r#settings: Option<r#ReturnsSettings>,
48    /// list of warnings
49    #[serde(rename = "warnings")]
50    pub r#warnings: Option<r#ReturnsWarnings>,
51}
52
53pub async fn call<'a>(
54    client: &'a mut moodle_client::MoodleClient,
55    params: &'a mut Params,
56) -> anyhow::Result<Returns> {
57    let json = client.post("tool_mobile_get_config", params).await?;
58
59    serde_json::from_value(json).map_err(|e| e.into())
60}
61
62pub async fn call_raw<'a>(
63    client: &'a mut moodle_client::MoodleClient,
64    params: &'a mut Params,
65) -> anyhow::Result<serde_json::Value> {
66    client.post("tool_mobile_get_config", params).await
67}