Skip to main content

data_for_seo/api/serp/google/
jobs.rs

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