Skip to main content

notion_client/endpoints/data_sources/
retrieve.rs

1use crate::{
2    endpoints::{parse_response, NOTION_URI},
3    objects::data_source::DataSource,
4    NotionClientError,
5};
6
7use super::DataSourcesEndpoint;
8
9impl DataSourcesEndpoint {
10    pub async fn retrieve_a_data_source(
11        &self,
12        data_source_id: &str,
13    ) -> Result<DataSource, NotionClientError> {
14        let result = self
15            .client
16            .get(format!(
17                "{notion_uri}/data_sources/{data_source_id}",
18                notion_uri = NOTION_URI,
19                data_source_id = data_source_id
20            ))
21            .send()
22            .await
23            .map_err(|e| NotionClientError::FailedToRequest { source: e })?;
24
25        let status = result.status();
26        let body = result
27            .text()
28            .await
29            .map_err(|e| NotionClientError::FailedToText { source: e })?;
30
31        parse_response(status, body)
32    }
33}