1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// DO NOT EDIT
// This file was @generated by Stone

#![allow(
    clippy::too_many_arguments,
    clippy::large_enum_variant,
    clippy::doc_markdown,
)]

/// This endpoint performs App Authentication, validating the supplied app key and secret, and
/// returns the supplied string, to allow you to test your code and connection to the Dropbox API.
/// It has no other effect. If you receive an HTTP 200 response with the supplied query, it
/// indicates at least part of the Dropbox API infrastructure is working and that the app key and
/// secret valid.
pub fn app(
    client: &impl crate::client_trait::AppAuthClient,
    arg: &EchoArg,
) -> crate::Result<Result<EchoResult, crate::NoError>> {
    crate::client_helpers::request(
        client,
        crate::client_trait::Endpoint::Api,
        crate::client_trait::Style::Rpc,
        "check/app",
        arg,
        None)
}

/// This endpoint performs User Authentication, validating the supplied access token, and returns
/// the supplied string, to allow you to test your code and connection to the Dropbox API. It has no
/// other effect. If you receive an HTTP 200 response with the supplied query, it indicates at least
/// part of the Dropbox API infrastructure is working and that the access token is valid.
pub fn user(
    client: &impl crate::client_trait::UserAuthClient,
    arg: &EchoArg,
) -> crate::Result<Result<EchoResult, crate::NoError>> {
    crate::client_helpers::request(
        client,
        crate::client_trait::Endpoint::Api,
        crate::client_trait::Style::Rpc,
        "check/user",
        arg,
        None)
}

/// EchoArg contains the arguments to be sent to the Dropbox servers.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct EchoArg {
    /// The string that you'd like to be echoed back to you.
    pub query: String,
}

impl Default for EchoArg {
    fn default() -> Self {
        EchoArg {
            query: String::new(),
        }
    }
}

impl EchoArg {
    pub fn with_query(mut self, value: String) -> Self {
        self.query = value;
        self
    }
}

const ECHO_ARG_FIELDS: &[&str] = &["query"];
impl EchoArg {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<EchoArg, V::Error> {
        let mut field_query = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "query" => {
                    if field_query.is_some() {
                        return Err(::serde::de::Error::duplicate_field("query"));
                    }
                    field_query = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = EchoArg {
            query: field_query.unwrap_or_else(String::new),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("query", &self.query)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for EchoArg {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = EchoArg;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a EchoArg struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                EchoArg::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("EchoArg", ECHO_ARG_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for EchoArg {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("EchoArg", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

/// EchoResult contains the result returned from the Dropbox servers.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] // structs may have more fields added in the future.
pub struct EchoResult {
    /// If everything worked correctly, this would be the same as query.
    pub result: String,
}

impl Default for EchoResult {
    fn default() -> Self {
        EchoResult {
            result: String::new(),
        }
    }
}

impl EchoResult {
    pub fn with_result(mut self, value: String) -> Self {
        self.result = value;
        self
    }
}

const ECHO_RESULT_FIELDS: &[&str] = &["result"];
impl EchoResult {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<EchoResult, V::Error> {
        let mut field_result = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "result" => {
                    if field_result.is_some() {
                        return Err(::serde::de::Error::duplicate_field("result"));
                    }
                    field_result = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = EchoResult {
            result: field_result.unwrap_or_else(String::new),
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("result", &self.result)?;
        Ok(())
    }
}

impl<'de> ::serde::de::Deserialize<'de> for EchoResult {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = EchoResult;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a EchoResult struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                EchoResult::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("EchoResult", ECHO_RESULT_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for EchoResult {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("EchoResult", 1)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}