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
//! Entities for Google Questions and Answers (`task_get` / `live`).
//! See <https://docs.dataforseo.com/v3/business_data/google/questions_and_answers/task_get/>.
use serde::{Deserialize, Serialize};
/// Result of a Questions and Answers request: metadata plus questions.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiQuestionsAndAnswersResult {
/// Business name or identifier the task was set for.
pub keyword: Option<String>,
/// Result type, e.g. `"questions_and_answers"`.
#[serde(rename = "type")]
pub result_type: Option<String>,
/// Search engine domain the data was collected from (e.g. `"google.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 Google results page the data was parsed from.
pub check_url: Option<String>,
/// UTC time the result was collected.
pub datetime: Option<String>,
/// Google-defined customer identifier (CID) for the business.
pub cid: Option<String>,
/// Unique Google feature identifier for the business.
pub feature_id: Option<String>,
/// Distinct element types present in `items`.
pub item_types: Option<Vec<String>>,
/// Number of questions in `items`.
pub items_count: Option<i64>,
/// Parsed questions, each with its answers.
pub items: Option<Vec<BusinessDataApiQuestionItem>>,
}
impl BusinessDataApiQuestionsAndAnswersResult {
/// Items of this result (empty slice when the API returned none).
pub fn items(&self) -> &[BusinessDataApiQuestionItem] {
self.items.as_deref().unwrap_or_default()
}
}
/// A single question, together with up to five answers in its `items`.
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiQuestionItem {
/// Element type, e.g. `"google_business_question_item"`.
#[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>,
/// Unique identifier of the question.
pub question_id: Option<String>,
/// Direct URL to the question.
pub url: Option<String>,
/// URL of the asker's profile image.
pub profile_image_url: Option<String>,
/// URL of the asker's Google profile.
pub profile_url: Option<String>,
/// Display name of the asker.
pub profile_name: Option<String>,
/// Current text of the question.
pub question_text: Option<String>,
/// Original question text before any edit.
pub original_question_text: Option<String>,
/// Human-readable time since the question was posted.
pub time_ago: Option<String>,
/// UTC timestamp the question was posted.
pub timestamp: Option<String>,
/// Answers to this question (up to five).
pub items: Option<Vec<BusinessDataApiAnswerItem>>,
}
/// A single answer nested inside a [`BusinessDataApiQuestionItem`].
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub struct BusinessDataApiAnswerItem {
/// Element type, e.g. `"google_business_answer_element"`.
#[serde(rename = "type")]
pub item_type: Option<String>,
/// Unique identifier of the answer.
pub answer_id: Option<String>,
/// URL of the responder's profile image.
pub profile_image_url: Option<String>,
/// URL of the responder's Google profile.
pub profile_url: Option<String>,
/// Display name of the responder.
pub profile_name: Option<String>,
/// Current text of the answer.
pub answer_text: Option<String>,
/// Original answer text before any edit.
pub original_answer_text: Option<String>,
/// Human-readable time since the answer was posted.
pub time_ago: Option<String>,
/// UTC timestamp the answer was posted.
pub timestamp: Option<String>,
/// Number of upvotes the answer received.
pub votes_count: Option<i64>,
}