floopy/resources/
feedback.rs1use std::sync::Arc;
2
3use reqwest::Method;
4
5use crate::constants::ENDPOINT_FEEDBACK;
6use crate::error::Result;
7use crate::http::HttpTransport;
8use crate::options::RequestOptions;
9use crate::types::{FeedbackSubmitParams, FeedbackSubmitResponse};
10
11use super::require;
12
13pub struct Feedback {
15 t: Arc<HttpTransport>,
16}
17
18impl Feedback {
19 pub(crate) fn new(t: Arc<HttpTransport>) -> Self {
20 Self { t }
21 }
22
23 pub async fn submit(
29 &self,
30 params: FeedbackSubmitParams,
31 req: impl Into<Option<RequestOptions>>,
32 ) -> Result<FeedbackSubmitResponse> {
33 let body =
34 serde_json::to_value(¶ms).map_err(|e| crate::Error::Decode(e.to_string()))?;
35 let (data, _) = self
36 .t
37 .request(
38 Method::POST,
39 ENDPOINT_FEEDBACK,
40 Some(&body),
41 &[],
42 req.into().as_ref(),
43 )
44 .await?;
45 require(data)
46 }
47}