Skip to main content

data_for_seo/api/serp/google/
local_finder.rs

1use crate::entity::{SerpApiGoogleLocalFinderTaskAdvanced, SerpApiGoogleLocalFinderTaskHtml};
2use crate::{DataForSeoApiResponse, SerpApiGoogle, SerpApiTaskReadyResult};
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6/// Google Local Finder SERP endpoint.
7/// <https://docs.dataforseo.com/v3/serp/google/local_finder/overview/>
8impl SerpApiGoogle<'_> {
9    /// <https://docs.dataforseo.com/v3/serp/google/local_finder/task_post/>
10    pub async fn local_finder_task_post(
11        &self,
12        data: Vec<SerpApiGoogleLocalFinderTaskPostRequest>,
13    ) -> DataForSeoApiResponse<Value> {
14        self.client
15            .http_post("/v3/serp/google/local_finder/task_post", &data)
16            .await
17    }
18    /// <https://docs.dataforseo.com/v3/serp/google/local_finder/tasks_ready/>
19    pub async fn local_finder_tasks_ready(&self) -> DataForSeoApiResponse<SerpApiTaskReadyResult> {
20        self.client
21            .serp()
22            .task_ready_se("google/local_finder")
23            .await
24    }
25    /// <https://docs.dataforseo.com/v3/serp/google/local_finder/task_get/advanced/>
26    pub async fn local_finder_task_get_advanced(
27        &self,
28        id: &str,
29    ) -> DataForSeoApiResponse<SerpApiGoogleLocalFinderTaskAdvanced> {
30        self.client
31            .http_get(format!("/v3/serp/google/local_finder/task_get/advanced/{id}").as_str())
32            .await
33    }
34    /// <https://docs.dataforseo.com/v3/serp/google/local_finder/task_get/html/>
35    pub async fn local_finder_task_get_html(
36        &self,
37        id: &str,
38    ) -> DataForSeoApiResponse<SerpApiGoogleLocalFinderTaskHtml> {
39        self.client
40            .http_get(format!("/v3/serp/google/local_finder/task_get/html/{id}").as_str())
41            .await
42    }
43    /// <https://docs.dataforseo.com/v3/serp/google/local_finder/live/advanced/>
44    pub async fn local_finder_live_advanced(
45        &self,
46        data: Vec<SerpApiGoogleLocalFinderTaskPostRequest>,
47    ) -> DataForSeoApiResponse<SerpApiGoogleLocalFinderTaskAdvanced> {
48        self.client
49            .http_post("/v3/serp/google/local_finder/live/advanced", &data)
50            .await
51    }
52}
53
54/// Request body for Google Local Finder task_post / live.
55/// See <https://docs.dataforseo.com/v3/serp/google/local_finder/task_post/>.
56#[derive(Debug, Default, Serialize, Deserialize, Clone)]
57pub struct SerpApiGoogleLocalFinderTaskPostRequest {
58    /// Search term the result was returned for.
59    pub keyword: String,
60    /// Task execution priority: 1 (normal) or 2 (high).
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub priority: Option<i32>,
63    /// Depth.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub depth: Option<i32>,
66    /// Full location name (e.g. "London,England,United Kingdom").
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub location_name: Option<String>,
69    /// DataForSEO location code the search was run for.
70    pub location_code: i32,
71    /// GPS coordinates the search was run for ("lat,lng,zoom").
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub location_coordinate: Option<String>,
74    /// Full language name of the search.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub language_name: Option<String>,
77    /// Language code the search was run for.
78    pub language_code: String,
79    /// Device.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub device: Option<String>,
82    /// Os.
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub os: Option<String>,
85    /// Min rating.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub min_rating: Option<i32>,
88    /// Time filter.
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub time_filter: Option<String>,
91    /// User-defined identifier echoed back on the result.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub tag: Option<String>,
94    /// URL of the postback.
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub postback_url: Option<String>,
97    /// Postback data.
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub postback_data: Option<String>,
100    /// URL of the pingback.
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub pingback_url: Option<String>,
103}
104
105impl SerpApiGoogleLocalFinderTaskPostRequest {
106    /// Creates a request with the required language and location codes.
107    /// Set `keyword` and any optional fields before sending.
108    pub fn new(language_code: String, location_code: i32) -> Self {
109        SerpApiGoogleLocalFinderTaskPostRequest {
110            language_code,
111            location_code,
112            ..SerpApiGoogleLocalFinderTaskPostRequest::default()
113        }
114    }
115}