sfr_slack_api/api/
files_remote_add.rs1use sfr_types as st;
6
7pub use st::FilesRemoteAddResponse;
8
9use crate::{Client, Request};
10use serde::Serialize;
11
12#[derive(Serialize, Debug)]
14pub struct FilesRemoteAdd(st::FilesRemoteAddRequest);
15
16const API_CODE: &str = "files.remote.add";
18
19impl FilesRemoteAdd {
20 async fn request_inner(&self, client: &Client) -> Result<FilesRemoteAddResponse, st::Error> {
22 #[allow(clippy::missing_docs_in_private_items)] const URL: &str = "https://slack.com/api/files.remote.add";
24
25 tracing::debug!("form = {self:?}");
26
27 let response = client
28 .client()
29 .post(URL)
30 .bearer_auth(client.token())
31 .form(&self)
32 .send()
33 .await
34 .map_err(|e| st::Error::failed_to_request_by_http(API_CODE, e))?;
35 tracing::debug!("response = {response:?}");
36
37 let body: serde_json::Value = response
38 .json()
39 .await
40 .map_err(|e| st::Error::failed_to_read_json(API_CODE, e))?;
41 tracing::debug!("body = {body:?}");
42
43 body.try_into()
44 }
45}
46
47impl From<st::FilesRemoteAddRequest> for FilesRemoteAdd {
48 fn from(inner: st::FilesRemoteAddRequest) -> Self {
49 Self(inner)
50 }
51}
52
53impl Request for FilesRemoteAdd {
54 type Response = FilesRemoteAddResponse;
55
56 async fn request(self, client: &Client) -> Result<Self::Response, st::Error> {
57 self.request_inner(client).await
58 }
59}