1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//! Entities for the Tripadvisor Search and Reviews endpoints.
//! See <https://docs.dataforseo.com/v3/business_data/tripadvisor/overview/>.
use crate::entity::{BusinessDataApiAddressInfo, BusinessDataApiRating};
use serde::{Deserialize, Serialize};
use serde_json::Value;
/// Task request for the Tripadvisor Search `task_post` endpoint.
/// See <https://docs.dataforseo.com/v3/business_data/tripadvisor/search/task_post/>.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorSearchTaskPost {
/// Business name or search query to look up on Tripadvisor.
pub keyword: String,
/// Full location name, e.g. `"London,England,United Kingdom"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub location_name: Option<String>,
/// Location code from the `locations` endpoint.
#[serde(skip_serializing_if = "Option::is_none")]
pub location_code: Option<i32>,
/// Full language name, e.g. `"English"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub language_name: Option<String>,
/// Language code, e.g. `"en"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
/// Business category to restrict the search to (e.g. `"hotels"`).
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
/// Task priority: `1` (normal, default) or `2` (high, extra cost).
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i32>,
/// User-defined task identifier (max 255 characters).
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
/// URL that receives the finished results via POST.
#[serde(skip_serializing_if = "Option::is_none")]
pub postback_url: Option<String>,
/// URL notified via GET when the task completes.
#[serde(skip_serializing_if = "Option::is_none")]
pub pingback_url: Option<String>,
}
impl BusinessDataApiTripadvisorSearchTaskPost {
/// Builds a Tripadvisor search task request for the given keyword.
pub fn new<T: Into<String>>(keyword: T) -> Self {
BusinessDataApiTripadvisorSearchTaskPost {
keyword: keyword.into(),
..BusinessDataApiTripadvisorSearchTaskPost::default()
}
}
}
/// Task request for the Tripadvisor Reviews `task_post` endpoint.
/// See <https://docs.dataforseo.com/v3/business_data/tripadvisor/reviews/task_post/>.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorReviewsTaskPost {
/// Business name or Tripadvisor URL path identifying the entity.
pub keyword: String,
/// Full location name, e.g. `"London,England,United Kingdom"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub location_name: Option<String>,
/// Location code from the `locations` endpoint.
#[serde(skip_serializing_if = "Option::is_none")]
pub location_code: Option<i32>,
/// Full language name, e.g. `"English"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub language_name: Option<String>,
/// Language code, e.g. `"en"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub language_code: Option<String>,
/// Number of reviews to parse (default `10`).
#[serde(skip_serializing_if = "Option::is_none")]
pub depth: Option<i32>,
/// Review ordering, e.g. `"most_recent"` or `"most_helpful"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub sort_by: Option<String>,
/// Task priority: `1` (normal, default) or `2` (high, extra cost).
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i32>,
/// User-defined task identifier (max 255 characters).
#[serde(skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
/// URL that receives the finished results via POST.
#[serde(skip_serializing_if = "Option::is_none")]
pub postback_url: Option<String>,
/// URL notified via GET when the task completes.
#[serde(skip_serializing_if = "Option::is_none")]
pub pingback_url: Option<String>,
}
impl BusinessDataApiTripadvisorReviewsTaskPost {
/// Builds a Tripadvisor reviews task request for the given keyword or URL path.
pub fn new<T: Into<String>>(keyword: T) -> Self {
BusinessDataApiTripadvisorReviewsTaskPost {
keyword: keyword.into(),
..BusinessDataApiTripadvisorReviewsTaskPost::default()
}
}
}
/// Result of a Tripadvisor Search request: metadata plus matched businesses.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorSearchResult {
/// Business name or query the task was set for.
pub keyword: Option<String>,
/// Result type, e.g. `"tripadvisor_search"`.
#[serde(rename = "type")]
pub result_type: Option<String>,
/// Source domain the data was collected from (e.g. `"tripadvisor.com"`).
pub se_domain: Option<String>,
/// Location code the task was run for.
pub location_code: Option<i32>,
/// Language code the task was run for.
pub language_code: Option<String>,
/// URL of the Tripadvisor results page the data was parsed from.
pub check_url: Option<String>,
/// UTC time the result was collected.
pub datetime: Option<String>,
/// Number of businesses in `items`.
pub items_count: Option<i64>,
/// Parsed business listings.
pub items: Option<Vec<BusinessDataApiTripadvisorSearchItem>>,
}
impl BusinessDataApiTripadvisorSearchResult {
/// Items of this result (empty slice when the API returned none).
pub fn items(&self) -> &[BusinessDataApiTripadvisorSearchItem] {
self.items.as_deref().unwrap_or_default()
}
}
/// A single business listing returned by Tripadvisor Search.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorSearchItem {
/// Element type, e.g. `"tripadvisor_search_organic"`.
#[serde(rename = "type")]
pub item_type: Option<String>,
/// Rank within elements of the same type.
pub rank_group: Option<i64>,
/// Rank across all elements regardless of type.
pub rank_absolute: Option<i64>,
/// Business name.
pub title: Option<String>,
/// Business category on Tripadvisor.
pub category: Option<String>,
/// Business description.
pub description: Option<String>,
/// Full URL of the business's Tripadvisor page.
pub url: Option<String>,
/// Path portion of the business's Tripadvisor page.
pub url_path: Option<String>,
/// Business website domain.
pub domain: Option<String>,
/// Whether the listing is a sponsored placement.
pub is_sponsored: Option<bool>,
/// Full postal address as a single string.
pub address: Option<String>,
/// Structured breakdown of the address.
pub address_info: Option<BusinessDataApiAddressInfo>,
/// Latitude of the business location.
pub latitude: Option<f64>,
/// Longitude of the business location.
pub longitude: Option<f64>,
/// Business phone number.
pub phone: Option<String>,
/// URL of the main business image.
pub main_image: Option<String>,
/// Price level indicator (e.g. `"$$"`).
pub price_level: Option<String>,
/// Price range shown on the listing (e.g. `"$$ - $$$"`).
pub price_rate: Option<String>,
/// Hotel class rating, for lodging businesses.
pub hotel_class: Option<f64>,
/// Total number of reviews the business has received.
pub reviews_count: Option<i64>,
/// Aggregated Tripadvisor rating.
pub rating: Option<BusinessDataApiRating>,
/// Vote counts per rating level (raw object).
pub rating_distribution: Option<Value>,
}
/// Result of a Tripadvisor Reviews request: metadata plus individual reviews.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorReviewsResult {
/// Business name or URL path the task was set for.
pub keyword: Option<String>,
/// Result type, e.g. `"tripadvisor_reviews"`.
#[serde(rename = "type")]
pub result_type: Option<String>,
/// Source domain the data was collected from (e.g. `"tripadvisor.com"`).
pub se_domain: Option<String>,
/// Location code the task was run for.
pub location_code: Option<i32>,
/// Language code the task was run for.
pub language_code: Option<String>,
/// URL of the Tripadvisor business page the data was parsed from.
pub check_url: Option<String>,
/// UTC time the result was collected.
pub datetime: Option<String>,
/// Business name the reviews belong to.
pub title: Option<String>,
/// Total number of reviews the business has received.
pub reviews_count: Option<i64>,
/// Aggregated Tripadvisor rating.
pub rating: Option<BusinessDataApiRating>,
/// Number of reviews in `items`.
pub items_count: Option<i64>,
/// Parsed individual reviews.
pub items: Option<Vec<BusinessDataApiTripadvisorReviewItem>>,
}
impl BusinessDataApiTripadvisorReviewsResult {
/// Items of this result (empty slice when the API returned none).
pub fn items(&self) -> &[BusinessDataApiTripadvisorReviewItem] {
self.items.as_deref().unwrap_or_default()
}
}
/// A single Tripadvisor review.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiTripadvisorReviewItem {
/// Element type, e.g. `"tripadvisor_review"`.
#[serde(rename = "type")]
pub item_type: Option<String>,
/// Rank within elements of the same type.
pub rank_group: Option<i64>,
/// Rank across all elements regardless of type.
pub rank_absolute: Option<i64>,
/// Placement of the element on the page.
pub position: Option<String>,
/// Unique identifier of the review.
pub review_id: Option<String>,
/// Direct URL to the review.
pub url: Option<String>,
/// Review headline.
pub title: Option<String>,
/// Review body text.
pub review_text: Option<String>,
/// Language code of the review.
pub language: Option<String>,
/// UTC timestamp the review was published.
pub timestamp: Option<String>,
/// Date of the visit the review describes.
pub date_of_visit: Option<String>,
/// Rating given by this review.
pub rating: Option<BusinessDataApiRating>,
/// Reviewer profile details (raw object).
pub user_profile: Option<Value>,
/// Images attached to the review (raw objects).
pub review_images: Option<Vec<Value>>,
/// Owner replies to the review (raw objects).
pub responses: Option<Vec<Value>>,
}