Skip to main content

data_for_seo/api/business_data/
mod.rs

1//! Business Data API domain: reviews and profiles from Google, Trustpilot,
2//! Tripadvisor, social media, and the business listings database.
3//! See <https://docs.dataforseo.com/v3/business_data/overview/>.
4
5use crate::entity::{
6    BusinessDataApiErrorItem, BusinessDataApiIdList, BusinessDataApiIdListRequest,
7};
8use crate::{DataForSeoApiResponse, DataForSeoClient};
9
10mod business_listings;
11mod google;
12mod social_media;
13mod tripadvisor;
14mod trustpilot;
15
16pub use business_listings::*;
17pub use google::*;
18pub use social_media::*;
19pub use tripadvisor::*;
20pub use trustpilot::*;
21
22/// Entry point for the Business Data API domain.
23/// See <https://docs.dataforseo.com/v3/business_data/overview/>.
24pub struct BusinessDataApi<'a> {
25    client: &'a DataForSeoClient,
26}
27
28impl DataForSeoClient {
29    /// Access the Business Data API (Google, Trustpilot, Tripadvisor, ...).
30    /// See <https://docs.dataforseo.com/v3/business_data/overview/>.
31    pub fn business_data(&self) -> BusinessDataApi<'_> {
32        BusinessDataApi { client: self }
33    }
34}
35
36impl BusinessDataApi<'_> {
37    /// Lists the ids of tasks set within the requested time range.
38    /// See <https://docs.dataforseo.com/v3/business_data/id_list/>.
39    pub async fn id_list(
40        &self,
41        data: Vec<BusinessDataApiIdListRequest>,
42    ) -> DataForSeoApiResponse<BusinessDataApiIdList> {
43        self.client
44            .http_post("/v3/business_data/id_list", &data)
45            .await
46    }
47
48    /// Lists errors that occurred while processing tasks.
49    /// See <https://docs.dataforseo.com/v3/business_data/errors/>.
50    pub async fn errors(
51        &self,
52        data: Vec<BusinessDataApiIdListRequest>,
53    ) -> DataForSeoApiResponse<BusinessDataApiErrorItem> {
54        self.client
55            .http_post("/v3/business_data/errors", &data)
56            .await
57    }
58}