Skip to main content

data_for_seo/api/dataforseo_labs/
apple.rs

1//! Apple App Store endpoints of the DataForSEO Labs API.
2//! See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/>.
3
4use crate::entity::{
5    DataForSeoLabsAppCompetitorItem, DataForSeoLabsAppIntersectionItem,
6    DataForSeoLabsAppKeywordItem, DataForSeoLabsBulkAppMetricsItem, DataForSeoLabsResult,
7};
8use crate::{DataForSeoApiResponse, DataForSeoClient};
9use serde::{Deserialize, Serialize};
10use serde_json::Value;
11use std::collections::HashMap;
12
13/// Apple App Store endpoints of the DataForSEO Labs API.
14pub struct DataForSeoLabsApiApple<'a> {
15    pub(crate) client: &'a DataForSeoClient,
16}
17
18impl DataForSeoLabsApiApple<'_> {
19    /// Keywords an App Store app ranks for.
20    /// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/keywords_for_app/live/>.
21    pub async fn keywords_for_app(
22        &self,
23        data: Vec<DataForSeoLabsAppleKeywordsForAppRequest>,
24    ) -> DataForSeoApiResponse<DataForSeoLabsResult<DataForSeoLabsAppKeywordItem>> {
25        self.client
26            .http_post("/v3/dataforseo_labs/apple/keywords_for_app/live", &data)
27            .await
28    }
29
30    /// App Store apps competing with a target app.
31    /// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/app_competitors/live/>.
32    pub async fn app_competitors(
33        &self,
34        data: Vec<DataForSeoLabsAppleAppCompetitorsRequest>,
35    ) -> DataForSeoApiResponse<DataForSeoLabsResult<DataForSeoLabsAppCompetitorItem>> {
36        self.client
37            .http_post("/v3/dataforseo_labs/apple/app_competitors/live", &data)
38            .await
39    }
40
41    /// Keywords a set of App Store apps rank for together.
42    /// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/app_intersection/live/>.
43    pub async fn app_intersection(
44        &self,
45        data: Vec<DataForSeoLabsAppleAppIntersectionRequest>,
46    ) -> DataForSeoApiResponse<DataForSeoLabsResult<DataForSeoLabsAppIntersectionItem>> {
47        self.client
48            .http_post("/v3/dataforseo_labs/apple/app_intersection/live", &data)
49            .await
50    }
51
52    /// Aggregated metrics for a batch of App Store apps.
53    /// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/bulk_app_metrics/live/>.
54    pub async fn bulk_app_metrics(
55        &self,
56        data: Vec<DataForSeoLabsAppleBulkAppMetricsRequest>,
57    ) -> DataForSeoApiResponse<DataForSeoLabsResult<DataForSeoLabsBulkAppMetricsItem>> {
58        self.client
59            .http_post("/v3/dataforseo_labs/apple/bulk_app_metrics/live", &data)
60            .await
61    }
62}
63
64/// Request body for Apple `keywords_for_app`.
65/// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/keywords_for_app/live/>.
66#[derive(Debug, Default, Serialize, Deserialize, Clone)]
67pub struct DataForSeoLabsAppleKeywordsForAppRequest {
68    /// Store identifier of the app.
69    pub app_id: String,
70    /// Full location name (e.g. `"United States"`); alternative to `location_code`.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub location_name: Option<String>,
73    /// Location code (e.g. `2840`); alternative to `location_name`.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub location_code: Option<i32>,
76    /// Full language name (e.g. `"English"`); alternative to `language_code`.
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub language_name: Option<String>,
79    /// Language code (e.g. `"en"`); alternative to `language_name`.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub language_code: Option<String>,
82    /// Array of filtering conditions applied to the results.
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub filters: Option<Vec<Value>>,
85    /// Sorting rules applied to the results.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub order_by: Option<Vec<String>>,
88    /// Maximum number of returned items (default 100, max 1000).
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub limit: Option<i32>,
91    /// Offset into the result set, for pagination.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub offset: Option<i32>,
94    /// User-defined task identifier (max 255 characters).
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub tag: Option<String>,
97}
98
99impl DataForSeoLabsAppleKeywordsForAppRequest {
100    /// Creates a request for the given App Store app id.
101    pub fn new(app_id: &str) -> DataForSeoLabsAppleKeywordsForAppRequest {
102        DataForSeoLabsAppleKeywordsForAppRequest {
103            app_id: app_id.to_string(),
104            ..Default::default()
105        }
106    }
107}
108
109/// Request body for Apple `app_competitors`.
110/// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/app_competitors/live/>.
111#[derive(Debug, Default, Serialize, Deserialize, Clone)]
112pub struct DataForSeoLabsAppleAppCompetitorsRequest {
113    /// Store identifier of the app.
114    pub app_id: String,
115    /// Full location name (e.g. `"United States"`); alternative to `location_code`.
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub location_name: Option<String>,
118    /// Location code (e.g. `2840`); alternative to `location_name`.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub location_code: Option<i32>,
121    /// Full language name (e.g. `"English"`); alternative to `language_code`.
122    #[serde(skip_serializing_if = "Option::is_none")]
123    pub language_name: Option<String>,
124    /// Language code (e.g. `"en"`); alternative to `language_name`.
125    #[serde(skip_serializing_if = "Option::is_none")]
126    pub language_code: Option<String>,
127    /// Array of filtering conditions applied to the results.
128    #[serde(skip_serializing_if = "Option::is_none")]
129    pub filters: Option<Vec<Value>>,
130    /// Sorting rules applied to the results.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub order_by: Option<Vec<String>>,
133    /// Maximum number of returned items (default 100, max 1000).
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub limit: Option<i32>,
136    /// Offset into the result set, for pagination.
137    #[serde(skip_serializing_if = "Option::is_none")]
138    pub offset: Option<i32>,
139    /// User-defined task identifier (max 255 characters).
140    #[serde(skip_serializing_if = "Option::is_none")]
141    pub tag: Option<String>,
142}
143
144impl DataForSeoLabsAppleAppCompetitorsRequest {
145    /// Creates a request for the given App Store app id.
146    pub fn new(app_id: &str) -> DataForSeoLabsAppleAppCompetitorsRequest {
147        DataForSeoLabsAppleAppCompetitorsRequest {
148            app_id: app_id.to_string(),
149            ..Default::default()
150        }
151    }
152}
153
154/// Request body for Apple `app_intersection`.
155/// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/app_intersection/live/>.
156#[derive(Debug, Default, Serialize, Deserialize, Clone)]
157pub struct DataForSeoLabsAppleAppIntersectionRequest {
158    /// App identifiers, keyed by an index string.
159    pub app_ids: HashMap<String, String>,
160    /// Full location name (e.g. `"United States"`); alternative to `location_code`.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub location_name: Option<String>,
163    /// Location code (e.g. `2840`); alternative to `location_name`.
164    #[serde(skip_serializing_if = "Option::is_none")]
165    pub location_code: Option<i32>,
166    /// Full language name (e.g. `"English"`); alternative to `language_code`.
167    #[serde(skip_serializing_if = "Option::is_none")]
168    pub language_name: Option<String>,
169    /// Language code (e.g. `"en"`); alternative to `language_name`.
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub language_code: Option<String>,
172    /// Array of filtering conditions applied to the results.
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub filters: Option<Vec<Value>>,
175    /// Sorting rules applied to the results.
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub order_by: Option<Vec<String>>,
178    /// Maximum number of returned items (default 100, max 1000).
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub limit: Option<i32>,
181    /// Offset into the result set, for pagination.
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub offset: Option<i32>,
184    /// User-defined task identifier (max 255 characters).
185    #[serde(skip_serializing_if = "Option::is_none")]
186    pub tag: Option<String>,
187}
188
189impl DataForSeoLabsAppleAppIntersectionRequest {
190    /// Creates a request over the given app ids map (index string -> app id).
191    pub fn new(app_ids: HashMap<String, String>) -> DataForSeoLabsAppleAppIntersectionRequest {
192        DataForSeoLabsAppleAppIntersectionRequest {
193            app_ids,
194            ..Default::default()
195        }
196    }
197}
198
199/// Request body for Apple `bulk_app_metrics`.
200/// See <https://docs.dataforseo.com/v3/dataforseo_labs/apple/bulk_app_metrics/live/>.
201#[derive(Debug, Default, Serialize, Deserialize, Clone)]
202pub struct DataForSeoLabsAppleBulkAppMetricsRequest {
203    /// App identifiers, keyed by an index string.
204    pub app_ids: Vec<String>,
205    /// Full location name (e.g. `"United States"`); alternative to `location_code`.
206    #[serde(skip_serializing_if = "Option::is_none")]
207    pub location_name: Option<String>,
208    /// Location code (e.g. `2840`); alternative to `location_name`.
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub location_code: Option<i32>,
211    /// Full language name (e.g. `"English"`); alternative to `language_code`.
212    #[serde(skip_serializing_if = "Option::is_none")]
213    pub language_name: Option<String>,
214    /// Language code (e.g. `"en"`); alternative to `language_name`.
215    #[serde(skip_serializing_if = "Option::is_none")]
216    pub language_code: Option<String>,
217    /// User-defined task identifier (max 255 characters).
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub tag: Option<String>,
220}
221
222impl DataForSeoLabsAppleBulkAppMetricsRequest {
223    /// Creates a request for the given App Store app ids.
224    pub fn new(app_ids: Vec<String>) -> DataForSeoLabsAppleBulkAppMetricsRequest {
225        DataForSeoLabsAppleBulkAppMetricsRequest {
226            app_ids,
227            ..Default::default()
228        }
229    }
230}