1use std::collections::HashMap;
5
6use serde::Deserialize;
7
8#[derive(Debug, Clone, Deserialize)]
9pub struct SuspiciousFactors {
10 pub is_proxy: bool,
11 pub is_tor_node: bool,
12 pub is_spam: bool,
13 pub is_crawler: bool,
14 pub is_datacenter: bool,
15 pub is_vpn: bool,
16 pub is_threat: bool,
17}
18
19#[derive(Debug, Clone, Deserialize)]
20pub struct Location {
21 pub country: Option<String>,
22 pub country_code: Option<String>,
23 pub city: Option<String>,
24 pub latitude: Option<f64>,
25 pub longitude: Option<f64>,
26 pub zip: Option<String>,
27 pub timezone: Option<String>,
28 pub local_time: Option<String>,
29 pub local_time_unix: Option<i64>,
30 pub is_daylight_savings: Option<bool>,
31}
32
33#[derive(Debug, Clone, Deserialize)]
34pub struct IpInfo {
35 pub ip: String,
36 pub isp: Option<String>,
37 pub asn: Option<String>,
38 pub suspicious_factors: SuspiciousFactors,
39 pub location: Location,
40}
41
42#[derive(Debug, Clone, Deserialize)]
43pub struct BatchIpLookupResponse {
44 pub results: HashMap<String, IpInfo>,
45 #[serde(default)]
46 pub total_processed: i32,
47 #[serde(default)]
48 pub successful_lookups: i32,
49 #[serde(default)]
50 pub failed_lookups: i32,
51}
52
53#[derive(Debug, Clone, Deserialize)]
54pub struct MxRecord {
55 pub priority: i32,
56 pub hostname: String,
57 pub ttl: i64,
58}
59
60#[derive(Debug, Clone, Deserialize)]
61pub struct EmailSyntax {
62 pub domain: Option<String>,
63 pub username: Option<String>,
64 pub is_valid: bool,
65 #[serde(default)]
66 pub error_reasons: Vec<String>,
67}
68
69#[derive(Debug, Clone, Deserialize)]
70pub struct EmailInfo {
71 pub email: String,
72 pub is_disposable: bool,
73 pub has_mx_records: bool,
74 #[serde(default)]
75 pub mx_records: Vec<MxRecord>,
76 pub syntax: EmailSyntax,
77}
78
79#[derive(Debug, Clone, Deserialize)]
80pub struct AdvancedSyntax {
81 pub username: String,
82 pub domain: String,
83 pub valid: bool,
84}
85
86#[derive(Debug, Clone, Deserialize)]
87pub struct AdvancedSmtp {
88 pub host_exists: bool,
89 pub full_inbox: bool,
90 pub catch_all: bool,
91 pub deliverable: bool,
92 pub disabled: bool,
93}
94
95#[derive(Debug, Clone, Deserialize)]
96pub struct AdvancedGravatar {
97 pub has_gravatar: bool,
98 pub gravatar_url: String,
99}
100
101#[derive(Debug, Clone, Deserialize)]
102pub struct AdvancedEmailValidation {
103 pub email: String,
104 pub reachable: String,
105 pub syntax: AdvancedSyntax,
106 pub smtp: Option<AdvancedSmtp>,
107 pub gravatar: Option<AdvancedGravatar>,
108 #[serde(default)]
109 pub suggestion: String,
110 pub disposable: bool,
111 pub role_account: bool,
112 pub free: bool,
113 pub has_mx_records: bool,
114}
115
116#[derive(Debug, Clone, Deserialize)]
117pub struct BatchEmailValidationResponse {
118 pub results: HashMap<String, AdvancedEmailValidation>,
119 #[serde(rename = "totalProcessed", default)]
120 pub total_processed: i32,
121 #[serde(rename = "successfulValidations", default)]
122 pub successful_validations: i32,
123 #[serde(rename = "failedValidations", default)]
124 pub failed_validations: i32,
125}
126
127#[derive(Debug, Clone, Deserialize)]
128pub struct IpFactors {
129 pub is_proxy: bool,
130 pub is_tor_node: bool,
131 pub is_spam: bool,
132 pub is_vpn: bool,
133 pub is_datacenter: bool,
134 pub risk_contribution: f64,
135}
136
137#[derive(Debug, Clone, Deserialize)]
138pub struct EmailFactors {
139 pub is_disposable: bool,
140 pub is_valid_syntax: bool,
141 pub risk_contribution: f64,
142}
143
144#[derive(Debug, Clone, Default, Deserialize)]
145pub struct RiskScoreFactors {
146 pub ip_factors: Option<IpFactors>,
147 pub email_factors: Option<EmailFactors>,
148}
149
150#[derive(Debug, Clone, Deserialize)]
151pub struct RiskScore {
152 pub score: f64,
153 pub risk_level: String,
154 pub ip: Option<String>,
155 pub email: Option<String>,
156 #[serde(default)]
157 pub factors: RiskScoreFactors,
158}
159
160#[derive(Debug, Clone, Deserialize)]
161pub struct TorDetection {
162 pub ip: String,
163 pub is_tor: bool,
164 #[serde(default)]
165 pub tor_node_count: i32,
166}
167
168#[derive(Debug, Clone, Deserialize)]
169pub struct AsnLookup {
170 pub ip: String,
171 pub asn: Option<i64>,
172 pub organization: Option<String>,
173 pub network: Option<String>,
174 #[serde(default)]
175 pub is_datacenter: bool,
176 pub country: Option<String>,
177 pub country_code: Option<String>,
178}
179
180#[derive(Debug, Clone, Deserialize)]
181pub struct DomainAge {
182 pub domain: String,
183 pub is_valid: bool,
184 pub registration_date: Option<String>,
185 pub age_in_years: Option<i32>,
186 pub age_in_days: Option<i64>,
187 pub error: Option<String>,
188}
189
190#[derive(Debug, Clone, Deserialize)]
191pub struct BatchDomainAgeResponse {
192 pub results: HashMap<String, DomainAge>,
193}
194
195#[derive(Debug, Clone, Deserialize)]
196pub struct WhoisRegistrar {
197 pub name: Option<String>,
198 pub url: Option<String>,
199 pub iana_id: Option<String>,
200}
201
202#[derive(Debug, Clone, Deserialize)]
203pub struct WhoisStatus {
204 pub code: String,
205 pub humanized: String,
206}
207
208#[derive(Debug, Clone, Deserialize)]
209pub struct Whois {
210 pub domain: String,
211 pub registrar: Option<WhoisRegistrar>,
212 pub registered_on: Option<String>,
213 pub expires_on: Option<String>,
214 pub updated_on: Option<String>,
215 #[serde(default)]
216 pub name_servers: Vec<String>,
217 #[serde(default)]
218 pub status: Vec<WhoisStatus>,
219 #[serde(default)]
220 pub raw: String,
221 pub error: Option<String>,
222}
223
224#[derive(Debug, Clone, Deserialize)]
225pub struct ReverseDns {
226 pub ip: String,
227 pub hostname: Option<String>,
228 pub ptr_record: Option<String>,
229 pub ttl: Option<i64>,
230}
231
232#[derive(Debug, Clone, Deserialize)]
233pub struct ForwardLookupRecord {
234 pub r#type: String,
235 pub address: String,
236 pub ttl: i64,
237}
238
239#[derive(Debug, Clone, Deserialize)]
240pub struct ForwardDns {
241 pub hostname: String,
242 #[serde(default)]
243 pub addresses: Vec<ForwardLookupRecord>,
244}
245
246#[derive(Debug, Clone, Deserialize)]
247pub struct MxLookup {
248 pub domain: String,
249 #[serde(default)]
250 pub mx_records: Vec<MxRecord>,
251}
252
253#[derive(Debug, Clone, Deserialize)]
254pub struct ApiLimitInfo {
255 pub limit: i64,
256 pub remaining: i64,
257 pub used: i64,
258 pub usage_percent: f64,
259}
260
261#[derive(Debug, Clone, Deserialize)]
262pub struct RateLimitInfo {
263 pub plan_id: String,
264 pub plan_name: Option<String>,
265 pub ip_api: ApiLimitInfo,
266 pub email_api: ApiLimitInfo,
267 pub interval_seconds: i64,
268 pub next_renewal_date: Option<String>,
269 pub status: Option<String>,
270}
271
272#[derive(Debug, Clone, Deserialize)]
273pub struct UsageSummary {
274 #[serde(rename = "apiKey")]
275 pub api_key: String,
276 #[serde(rename = "apiType")]
277 pub api_type: String,
278 #[serde(rename = "periodStart")]
279 pub period_start: String,
280 #[serde(rename = "periodEnd")]
281 pub period_end: String,
282 #[serde(rename = "totalRequests")]
283 pub total_requests: i64,
284 #[serde(rename = "successfulRequests")]
285 pub successful_requests: i64,
286 #[serde(rename = "rateLimitedRequests")]
287 pub rate_limited_requests: i64,
288 #[serde(rename = "quotaConsumed")]
289 pub quota_consumed: i64,
290 #[serde(rename = "batchOperations")]
291 pub batch_operations: i64,
292 #[serde(rename = "avgRequestDurationMs")]
293 pub avg_request_duration_ms: Option<f64>,
294}