use std::sync::Arc;
use reqwest::Method;
use crate::constants::ENDPOINT_FEEDBACK;
use crate::error::Result;
use crate::http::HttpTransport;
use crate::options::RequestOptions;
use crate::types::{FeedbackSubmitParams, FeedbackSubmitResponse};
use super::require;
pub struct Feedback {
t: Arc<HttpTransport>,
}
impl Feedback {
pub(crate) fn new(t: Arc<HttpTransport>) -> Self {
Self { t }
}
pub async fn submit(
&self,
params: FeedbackSubmitParams,
req: impl Into<Option<RequestOptions>>,
) -> Result<FeedbackSubmitResponse> {
let body =
serde_json::to_value(¶ms).map_err(|e| crate::Error::Decode(e.to_string()))?;
let (data, _) = self
.t
.request(
Method::POST,
ENDPOINT_FEEDBACK,
Some(&body),
&[],
req.into().as_ref(),
)
.await?;
require(data)
}
}