Skip to main content

data_for_seo/api/app_data/
mod.rs

1use crate::entity::{AppDataApiError, AppDataApiIdList};
2use crate::{DataForSeoApiResponse, DataForSeoClient};
3use serde::{Deserialize, Serialize};
4
5mod apple;
6mod google;
7
8pub use apple::*;
9pub use google::*;
10
11/// Entry point for the App Data API domain (Google Play and Apple App Store).
12/// See <https://docs.dataforseo.com/v3/app_data/>.
13pub struct AppDataApi<'a> {
14    client: &'a DataForSeoClient,
15}
16
17impl DataForSeoClient {
18    /// Returns the App Data API. See <https://docs.dataforseo.com/v3/app_data/>.
19    pub fn app_data(&self) -> AppDataApi<'_> {
20        AppDataApi { client: self }
21    }
22}
23
24impl AppDataApi<'_> {
25    /// Task IDs of the App Data tasks set within a time range.
26    /// See <https://docs.dataforseo.com/v3/app_data/id_list/>.
27    pub async fn id_list(
28        &self,
29        data: Vec<AppDataApiIdListPost>,
30    ) -> DataForSeoApiResponse<AppDataApiIdList> {
31        self.client.http_post("/v3/app_data/id_list", &data).await
32    }
33
34    /// App Data tasks that responded with an error within the last 7 days.
35    /// See <https://docs.dataforseo.com/v3/app_data/errors/>.
36    pub async fn errors(
37        &self,
38        data: Vec<AppDataApiErrorsPost>,
39    ) -> DataForSeoApiResponse<AppDataApiError> {
40        self.client.http_post("/v3/app_data/errors", &data).await
41    }
42}
43
44/// Request body for the App Data `id_list` endpoint.
45/// See <https://docs.dataforseo.com/v3/app_data/id_list/>.
46#[derive(Debug, Default, Serialize, Deserialize, Clone)]
47pub struct AppDataApiIdListPost {
48    /// Start of the time range to list tasks for (UTC).
49    pub datetime_from: String,
50    /// End of the time range to list tasks for (UTC).
51    pub datetime_to: String,
52    /// Maximum number of task IDs to return (max 1000).
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub limit: Option<i32>,
55    /// Offset into the result set.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub offset: Option<i32>,
58    /// Sort order by execution time (`asc` or `desc`).
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub sort: Option<String>,
61    /// Include the original POST parameters of each task in the response.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub include_metadata: Option<bool>,
64}
65
66impl AppDataApiIdListPost {
67    /// Builds an `id_list` request for the `[datetime_from, datetime_to]` range.
68    pub fn new(datetime_from: String, datetime_to: String) -> Self {
69        AppDataApiIdListPost {
70            datetime_from,
71            datetime_to,
72            ..AppDataApiIdListPost::default()
73        }
74    }
75}
76
77/// Request body for the App Data `errors` endpoint.
78/// See <https://docs.dataforseo.com/v3/app_data/errors/>.
79#[derive(Debug, Default, Serialize, Deserialize, Clone)]
80pub struct AppDataApiErrorsPost {
81    /// Maximum number of errored tasks to return (max 1000).
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub limit: Option<i32>,
84    /// Offset into the result set.
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub offset: Option<i32>,
87    /// Restrict results to a specific API function.
88    #[serde(skip_serializing_if = "Option::is_none")]
89    pub filtered_function: Option<String>,
90    /// Start of the time range to filter errors for (UTC, within the last 7 days).
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub datetime_from: Option<String>,
93    /// End of the time range to filter errors for (UTC, within the last 7 days).
94    #[serde(skip_serializing_if = "Option::is_none")]
95    pub datetime_to: Option<String>,
96}
97
98/// Request body item for App Searches `task_post`.
99/// See <https://docs.dataforseo.com/v3/app_data/google/app_searches/task_post/>.
100#[derive(Debug, Default, Serialize, Deserialize, Clone)]
101pub struct AppDataApiAppSearchesTaskPostRequest {
102    /// Search query to run against the app store.
103    pub keyword: String,
104    /// Full location name to localize results to.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub location_name: Option<String>,
107    /// Location code to localize results to.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub location_code: Option<i32>,
110    /// Full language name to localize results to.
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub language_name: Option<String>,
113    /// Language code to localize results to.
114    #[serde(skip_serializing_if = "Option::is_none")]
115    pub language_code: Option<String>,
116    /// App store domain to search against.
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub se_domain: Option<String>,
119    /// Number of results to return (max 200).
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub depth: Option<i32>,
122    /// Task execution priority (`1` normal, `2` high).
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub priority: Option<i32>,
125    /// User-defined task identifier echoed back in results.
126    #[serde(skip_serializing_if = "Option::is_none")]
127    pub tag: Option<String>,
128    /// URL to receive the completed result via POST.
129    #[serde(skip_serializing_if = "Option::is_none")]
130    pub postback_url: Option<String>,
131    /// Result format to post back (`advanced` or `html`).
132    #[serde(skip_serializing_if = "Option::is_none")]
133    pub postback_data: Option<String>,
134    /// URL notified via GET when the task completes.
135    #[serde(skip_serializing_if = "Option::is_none")]
136    pub pingback_url: Option<String>,
137}
138
139impl AppDataApiAppSearchesTaskPostRequest {
140    /// Builds an App Searches request for `keyword` in the given location/language.
141    pub fn new(keyword: String, location_code: i32, language_code: String) -> Self {
142        AppDataApiAppSearchesTaskPostRequest {
143            keyword,
144            location_code: Some(location_code),
145            language_code: Some(language_code),
146            ..AppDataApiAppSearchesTaskPostRequest::default()
147        }
148    }
149}
150
151/// Request body item for App List `task_post`.
152/// See <https://docs.dataforseo.com/v3/app_data/google/app_list/task_post/>.
153#[derive(Debug, Default, Serialize, Deserialize, Clone)]
154pub struct AppDataApiAppListTaskPostRequest {
155    /// Store collection to list (e.g. `topselling_free`).
156    pub app_collection: String,
157    /// Store category to filter the collection by.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub app_category: Option<String>,
160    /// Age-rating bucket to filter apps by.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub age_rating: Option<String>,
163    /// Full location name to localize results to.
164    #[serde(skip_serializing_if = "Option::is_none")]
165    pub location_name: Option<String>,
166    /// Location code to localize results to.
167    #[serde(skip_serializing_if = "Option::is_none")]
168    pub location_code: Option<i32>,
169    /// Full language name to localize results to.
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub language_name: Option<String>,
172    /// Language code to localize results to.
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub language_code: Option<String>,
175    /// Number of apps to return (max 200).
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub depth: Option<i32>,
178    /// Task execution priority (`1` normal, `2` high).
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub priority: Option<i32>,
181    /// User-defined task identifier echoed back in results.
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub tag: Option<String>,
184    /// URL to receive the completed result via POST.
185    #[serde(skip_serializing_if = "Option::is_none")]
186    pub postback_url: Option<String>,
187    /// Result format to post back (`advanced` or `html`).
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub postback_data: Option<String>,
190    /// URL notified via GET when the task completes.
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub pingback_url: Option<String>,
193}
194
195impl AppDataApiAppListTaskPostRequest {
196    /// Builds an App List request for `app_collection` in the given location/language.
197    pub fn new(app_collection: String, location_code: i32, language_code: String) -> Self {
198        AppDataApiAppListTaskPostRequest {
199            app_collection,
200            location_code: Some(location_code),
201            language_code: Some(language_code),
202            ..AppDataApiAppListTaskPostRequest::default()
203        }
204    }
205}
206
207/// Request body item for App Info `task_post`.
208/// See <https://docs.dataforseo.com/v3/app_data/google/app_info/task_post/>.
209#[derive(Debug, Default, Serialize, Deserialize, Clone)]
210pub struct AppDataApiAppInfoTaskPostRequest {
211    /// Store identifier of the application to fetch.
212    pub app_id: String,
213    /// Full location name to localize results to.
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub location_name: Option<String>,
216    /// Location code to localize results to.
217    #[serde(skip_serializing_if = "Option::is_none")]
218    pub location_code: Option<i32>,
219    /// Full language name to localize results to.
220    #[serde(skip_serializing_if = "Option::is_none")]
221    pub language_name: Option<String>,
222    /// Language code to localize results to.
223    #[serde(skip_serializing_if = "Option::is_none")]
224    pub language_code: Option<String>,
225    /// Task execution priority (`1` normal, `2` high).
226    #[serde(skip_serializing_if = "Option::is_none")]
227    pub priority: Option<i32>,
228    /// User-defined task identifier echoed back in results.
229    #[serde(skip_serializing_if = "Option::is_none")]
230    pub tag: Option<String>,
231    /// URL to receive the completed result via POST.
232    #[serde(skip_serializing_if = "Option::is_none")]
233    pub postback_url: Option<String>,
234    /// Result format to post back (`advanced` or `html`).
235    #[serde(skip_serializing_if = "Option::is_none")]
236    pub postback_data: Option<String>,
237    /// URL notified via GET when the task completes.
238    #[serde(skip_serializing_if = "Option::is_none")]
239    pub pingback_url: Option<String>,
240}
241
242impl AppDataApiAppInfoTaskPostRequest {
243    /// Builds an App Info request for `app_id` in the given location/language.
244    pub fn new(app_id: String, location_code: i32, language_code: String) -> Self {
245        AppDataApiAppInfoTaskPostRequest {
246            app_id,
247            location_code: Some(location_code),
248            language_code: Some(language_code),
249            ..AppDataApiAppInfoTaskPostRequest::default()
250        }
251    }
252}
253
254/// Request body item for App Reviews `task_post`.
255/// See <https://docs.dataforseo.com/v3/app_data/google/app_reviews/task_post/>.
256#[derive(Debug, Default, Serialize, Deserialize, Clone)]
257pub struct AppDataApiAppReviewsTaskPostRequest {
258    /// Store identifier of the application to fetch reviews for.
259    pub app_id: String,
260    /// Full location name to localize results to.
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub location_name: Option<String>,
263    /// Location code to localize results to.
264    #[serde(skip_serializing_if = "Option::is_none")]
265    pub location_code: Option<i32>,
266    /// Full language name to localize results to.
267    #[serde(skip_serializing_if = "Option::is_none")]
268    pub language_name: Option<String>,
269    /// Language code to localize results to.
270    #[serde(skip_serializing_if = "Option::is_none")]
271    pub language_code: Option<String>,
272    /// Number of reviews to return.
273    #[serde(skip_serializing_if = "Option::is_none")]
274    pub depth: Option<i32>,
275    /// Task execution priority (`1` normal, `2` high).
276    #[serde(skip_serializing_if = "Option::is_none")]
277    pub priority: Option<i32>,
278    /// User-defined task identifier echoed back in results.
279    #[serde(skip_serializing_if = "Option::is_none")]
280    pub tag: Option<String>,
281    /// URL to receive the completed result via POST.
282    #[serde(skip_serializing_if = "Option::is_none")]
283    pub postback_url: Option<String>,
284    /// Result format to post back (`advanced` or `html`).
285    #[serde(skip_serializing_if = "Option::is_none")]
286    pub postback_data: Option<String>,
287    /// URL notified via GET when the task completes.
288    #[serde(skip_serializing_if = "Option::is_none")]
289    pub pingback_url: Option<String>,
290}
291
292impl AppDataApiAppReviewsTaskPostRequest {
293    /// Builds an App Reviews request for `app_id` in the given location/language.
294    pub fn new(app_id: String, location_code: i32, language_code: String) -> Self {
295        AppDataApiAppReviewsTaskPostRequest {
296            app_id,
297            location_code: Some(location_code),
298            language_code: Some(language_code),
299            ..AppDataApiAppReviewsTaskPostRequest::default()
300        }
301    }
302}