1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AnalyticsDataServiceGetAttributeDistributionError {
22 DefaultResponse(models::ErrorResponse),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AnalyticsDataServiceGetAttributeMetricError {
30 DefaultResponse(models::ErrorResponse),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AnalyticsDataServiceGetAttributeValuesError {
38 DefaultResponse(models::ErrorResponse),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AnalyticsDataServiceGetBreakdownError {
46 DefaultResponse(models::ErrorResponse),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum AnalyticsDataServiceGetDeviceDistributionError {
54 DefaultResponse(models::ErrorResponse),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum AnalyticsDataServiceGetGeoBreakdownError {
62 DefaultResponse(models::ErrorResponse),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum AnalyticsDataServiceGetGroupedTimeSeriesError {
70 DefaultResponse(models::ErrorResponse),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AnalyticsDataServiceGetHourOfDayDistributionError {
78 DefaultResponse(models::ErrorResponse),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum AnalyticsDataServiceGetStepFunnelError {
86 DefaultResponse(models::ErrorResponse),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AnalyticsDataServiceGetTopLinksError {
94 DefaultResponse(models::ErrorResponse),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum AnalyticsDataServiceGetVisitorTrendsError {
102 DefaultResponse(models::ErrorResponse),
103 UnknownValue(serde_json::Value),
104}
105
106
107pub async fn analytics_data_service_get_attribute_distribution(configuration: &configuration::Configuration, get_attribute_distribution_request: models::GetAttributeDistributionRequest) -> Result<models::GetAttributeDistributionResponse, Error<AnalyticsDataServiceGetAttributeDistributionError>> {
109 let p_body_get_attribute_distribution_request = get_attribute_distribution_request;
111
112 let uri_str = format!("{}/v1/analytics/attributes/distribution", configuration.base_path);
113 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
114
115 if let Some(ref user_agent) = configuration.user_agent {
116 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117 }
118 if let Some(ref token) = configuration.bearer_access_token {
119 req_builder = req_builder.bearer_auth(token.to_owned());
120 };
121 req_builder = req_builder.json(&p_body_get_attribute_distribution_request);
122
123 let req = req_builder.build()?;
124 let resp = configuration.client.execute(req).await?;
125
126 let status = resp.status();
127 let content_type = resp
128 .headers()
129 .get("content-type")
130 .and_then(|v| v.to_str().ok())
131 .unwrap_or("application/octet-stream");
132 let content_type = super::ContentType::from(content_type);
133
134 if !status.is_client_error() && !status.is_server_error() {
135 let content = resp.text().await?;
136 match content_type {
137 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
138 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAttributeDistributionResponse`"))),
139 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAttributeDistributionResponse`")))),
140 }
141 } else {
142 let content = resp.text().await?;
143 let entity: Option<AnalyticsDataServiceGetAttributeDistributionError> = serde_json::from_str(&content).ok();
144 Err(Error::ResponseError(ResponseContent { status, content, entity }))
145 }
146}
147
148pub async fn analytics_data_service_get_attribute_metric(configuration: &configuration::Configuration, get_attribute_metric_request: models::GetAttributeMetricRequest) -> Result<models::GetAttributeMetricResponse, Error<AnalyticsDataServiceGetAttributeMetricError>> {
150 let p_body_get_attribute_metric_request = get_attribute_metric_request;
152
153 let uri_str = format!("{}/v1/analytics/attributes/metric", configuration.base_path);
154 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
155
156 if let Some(ref user_agent) = configuration.user_agent {
157 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
158 }
159 if let Some(ref token) = configuration.bearer_access_token {
160 req_builder = req_builder.bearer_auth(token.to_owned());
161 };
162 req_builder = req_builder.json(&p_body_get_attribute_metric_request);
163
164 let req = req_builder.build()?;
165 let resp = configuration.client.execute(req).await?;
166
167 let status = resp.status();
168 let content_type = resp
169 .headers()
170 .get("content-type")
171 .and_then(|v| v.to_str().ok())
172 .unwrap_or("application/octet-stream");
173 let content_type = super::ContentType::from(content_type);
174
175 if !status.is_client_error() && !status.is_server_error() {
176 let content = resp.text().await?;
177 match content_type {
178 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
179 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAttributeMetricResponse`"))),
180 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAttributeMetricResponse`")))),
181 }
182 } else {
183 let content = resp.text().await?;
184 let entity: Option<AnalyticsDataServiceGetAttributeMetricError> = serde_json::from_str(&content).ok();
185 Err(Error::ResponseError(ResponseContent { status, content, entity }))
186 }
187}
188
189pub async fn analytics_data_service_get_attribute_values(configuration: &configuration::Configuration, get_attribute_values_request: models::GetAttributeValuesRequest) -> Result<models::GetAttributeValuesResponse, Error<AnalyticsDataServiceGetAttributeValuesError>> {
191 let p_body_get_attribute_values_request = get_attribute_values_request;
193
194 let uri_str = format!("{}/v1/analytics/attributes/values", configuration.base_path);
195 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
196
197 if let Some(ref user_agent) = configuration.user_agent {
198 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
199 }
200 if let Some(ref token) = configuration.bearer_access_token {
201 req_builder = req_builder.bearer_auth(token.to_owned());
202 };
203 req_builder = req_builder.json(&p_body_get_attribute_values_request);
204
205 let req = req_builder.build()?;
206 let resp = configuration.client.execute(req).await?;
207
208 let status = resp.status();
209 let content_type = resp
210 .headers()
211 .get("content-type")
212 .and_then(|v| v.to_str().ok())
213 .unwrap_or("application/octet-stream");
214 let content_type = super::ContentType::from(content_type);
215
216 if !status.is_client_error() && !status.is_server_error() {
217 let content = resp.text().await?;
218 match content_type {
219 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
220 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAttributeValuesResponse`"))),
221 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAttributeValuesResponse`")))),
222 }
223 } else {
224 let content = resp.text().await?;
225 let entity: Option<AnalyticsDataServiceGetAttributeValuesError> = serde_json::from_str(&content).ok();
226 Err(Error::ResponseError(ResponseContent { status, content, entity }))
227 }
228}
229
230pub async fn analytics_data_service_get_breakdown(configuration: &configuration::Configuration, get_breakdown_request: models::GetBreakdownRequest) -> Result<models::GetBreakdownResponse, Error<AnalyticsDataServiceGetBreakdownError>> {
232 let p_body_get_breakdown_request = get_breakdown_request;
234
235 let uri_str = format!("{}/v1/analytics/breakdown", configuration.base_path);
236 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
237
238 if let Some(ref user_agent) = configuration.user_agent {
239 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
240 }
241 if let Some(ref token) = configuration.bearer_access_token {
242 req_builder = req_builder.bearer_auth(token.to_owned());
243 };
244 req_builder = req_builder.json(&p_body_get_breakdown_request);
245
246 let req = req_builder.build()?;
247 let resp = configuration.client.execute(req).await?;
248
249 let status = resp.status();
250 let content_type = resp
251 .headers()
252 .get("content-type")
253 .and_then(|v| v.to_str().ok())
254 .unwrap_or("application/octet-stream");
255 let content_type = super::ContentType::from(content_type);
256
257 if !status.is_client_error() && !status.is_server_error() {
258 let content = resp.text().await?;
259 match content_type {
260 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
261 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetBreakdownResponse`"))),
262 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetBreakdownResponse`")))),
263 }
264 } else {
265 let content = resp.text().await?;
266 let entity: Option<AnalyticsDataServiceGetBreakdownError> = serde_json::from_str(&content).ok();
267 Err(Error::ResponseError(ResponseContent { status, content, entity }))
268 }
269}
270
271pub async fn analytics_data_service_get_device_distribution(configuration: &configuration::Configuration, get_device_distribution_request: models::GetDeviceDistributionRequest) -> Result<models::GetDeviceDistributionResponse, Error<AnalyticsDataServiceGetDeviceDistributionError>> {
273 let p_body_get_device_distribution_request = get_device_distribution_request;
275
276 let uri_str = format!("{}/v1/analytics/devices", configuration.base_path);
277 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
278
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282 if let Some(ref token) = configuration.bearer_access_token {
283 req_builder = req_builder.bearer_auth(token.to_owned());
284 };
285 req_builder = req_builder.json(&p_body_get_device_distribution_request);
286
287 let req = req_builder.build()?;
288 let resp = configuration.client.execute(req).await?;
289
290 let status = resp.status();
291 let content_type = resp
292 .headers()
293 .get("content-type")
294 .and_then(|v| v.to_str().ok())
295 .unwrap_or("application/octet-stream");
296 let content_type = super::ContentType::from(content_type);
297
298 if !status.is_client_error() && !status.is_server_error() {
299 let content = resp.text().await?;
300 match content_type {
301 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
302 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetDeviceDistributionResponse`"))),
303 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetDeviceDistributionResponse`")))),
304 }
305 } else {
306 let content = resp.text().await?;
307 let entity: Option<AnalyticsDataServiceGetDeviceDistributionError> = serde_json::from_str(&content).ok();
308 Err(Error::ResponseError(ResponseContent { status, content, entity }))
309 }
310}
311
312pub async fn analytics_data_service_get_geo_breakdown(configuration: &configuration::Configuration, get_geo_breakdown_request: models::GetGeoBreakdownRequest) -> Result<models::GetGeoBreakdownResponse, Error<AnalyticsDataServiceGetGeoBreakdownError>> {
314 let p_body_get_geo_breakdown_request = get_geo_breakdown_request;
316
317 let uri_str = format!("{}/v1/analytics/geo", configuration.base_path);
318 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
319
320 if let Some(ref user_agent) = configuration.user_agent {
321 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
322 }
323 if let Some(ref token) = configuration.bearer_access_token {
324 req_builder = req_builder.bearer_auth(token.to_owned());
325 };
326 req_builder = req_builder.json(&p_body_get_geo_breakdown_request);
327
328 let req = req_builder.build()?;
329 let resp = configuration.client.execute(req).await?;
330
331 let status = resp.status();
332 let content_type = resp
333 .headers()
334 .get("content-type")
335 .and_then(|v| v.to_str().ok())
336 .unwrap_or("application/octet-stream");
337 let content_type = super::ContentType::from(content_type);
338
339 if !status.is_client_error() && !status.is_server_error() {
340 let content = resp.text().await?;
341 match content_type {
342 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
343 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGeoBreakdownResponse`"))),
344 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetGeoBreakdownResponse`")))),
345 }
346 } else {
347 let content = resp.text().await?;
348 let entity: Option<AnalyticsDataServiceGetGeoBreakdownError> = serde_json::from_str(&content).ok();
349 Err(Error::ResponseError(ResponseContent { status, content, entity }))
350 }
351}
352
353pub async fn analytics_data_service_get_grouped_time_series(configuration: &configuration::Configuration, get_grouped_time_series_request: models::GetGroupedTimeSeriesRequest) -> Result<models::GetGroupedTimeSeriesResponse, Error<AnalyticsDataServiceGetGroupedTimeSeriesError>> {
355 let p_body_get_grouped_time_series_request = get_grouped_time_series_request;
357
358 let uri_str = format!("{}/v1/analytics/timeseries", configuration.base_path);
359 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
360
361 if let Some(ref user_agent) = configuration.user_agent {
362 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
363 }
364 if let Some(ref token) = configuration.bearer_access_token {
365 req_builder = req_builder.bearer_auth(token.to_owned());
366 };
367 req_builder = req_builder.json(&p_body_get_grouped_time_series_request);
368
369 let req = req_builder.build()?;
370 let resp = configuration.client.execute(req).await?;
371
372 let status = resp.status();
373 let content_type = resp
374 .headers()
375 .get("content-type")
376 .and_then(|v| v.to_str().ok())
377 .unwrap_or("application/octet-stream");
378 let content_type = super::ContentType::from(content_type);
379
380 if !status.is_client_error() && !status.is_server_error() {
381 let content = resp.text().await?;
382 match content_type {
383 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
384 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGroupedTimeSeriesResponse`"))),
385 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetGroupedTimeSeriesResponse`")))),
386 }
387 } else {
388 let content = resp.text().await?;
389 let entity: Option<AnalyticsDataServiceGetGroupedTimeSeriesError> = serde_json::from_str(&content).ok();
390 Err(Error::ResponseError(ResponseContent { status, content, entity }))
391 }
392}
393
394pub async fn analytics_data_service_get_hour_of_day_distribution(configuration: &configuration::Configuration, get_hour_of_day_distribution_request: models::GetHourOfDayDistributionRequest) -> Result<models::GetHourOfDayDistributionResponse, Error<AnalyticsDataServiceGetHourOfDayDistributionError>> {
396 let p_body_get_hour_of_day_distribution_request = get_hour_of_day_distribution_request;
398
399 let uri_str = format!("{}/v1/analytics/hours", configuration.base_path);
400 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
401
402 if let Some(ref user_agent) = configuration.user_agent {
403 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
404 }
405 if let Some(ref token) = configuration.bearer_access_token {
406 req_builder = req_builder.bearer_auth(token.to_owned());
407 };
408 req_builder = req_builder.json(&p_body_get_hour_of_day_distribution_request);
409
410 let req = req_builder.build()?;
411 let resp = configuration.client.execute(req).await?;
412
413 let status = resp.status();
414 let content_type = resp
415 .headers()
416 .get("content-type")
417 .and_then(|v| v.to_str().ok())
418 .unwrap_or("application/octet-stream");
419 let content_type = super::ContentType::from(content_type);
420
421 if !status.is_client_error() && !status.is_server_error() {
422 let content = resp.text().await?;
423 match content_type {
424 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
425 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetHourOfDayDistributionResponse`"))),
426 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetHourOfDayDistributionResponse`")))),
427 }
428 } else {
429 let content = resp.text().await?;
430 let entity: Option<AnalyticsDataServiceGetHourOfDayDistributionError> = serde_json::from_str(&content).ok();
431 Err(Error::ResponseError(ResponseContent { status, content, entity }))
432 }
433}
434
435pub async fn analytics_data_service_get_step_funnel(configuration: &configuration::Configuration, get_step_funnel_request: models::GetStepFunnelRequest) -> Result<models::GetStepFunnelResponse, Error<AnalyticsDataServiceGetStepFunnelError>> {
437 let p_body_get_step_funnel_request = get_step_funnel_request;
439
440 let uri_str = format!("{}/v1/analytics/funnel", configuration.base_path);
441 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
442
443 if let Some(ref user_agent) = configuration.user_agent {
444 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
445 }
446 if let Some(ref token) = configuration.bearer_access_token {
447 req_builder = req_builder.bearer_auth(token.to_owned());
448 };
449 req_builder = req_builder.json(&p_body_get_step_funnel_request);
450
451 let req = req_builder.build()?;
452 let resp = configuration.client.execute(req).await?;
453
454 let status = resp.status();
455 let content_type = resp
456 .headers()
457 .get("content-type")
458 .and_then(|v| v.to_str().ok())
459 .unwrap_or("application/octet-stream");
460 let content_type = super::ContentType::from(content_type);
461
462 if !status.is_client_error() && !status.is_server_error() {
463 let content = resp.text().await?;
464 match content_type {
465 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
466 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetStepFunnelResponse`"))),
467 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetStepFunnelResponse`")))),
468 }
469 } else {
470 let content = resp.text().await?;
471 let entity: Option<AnalyticsDataServiceGetStepFunnelError> = serde_json::from_str(&content).ok();
472 Err(Error::ResponseError(ResponseContent { status, content, entity }))
473 }
474}
475
476pub async fn analytics_data_service_get_top_links(configuration: &configuration::Configuration, get_top_links_request: models::GetTopLinksRequest) -> Result<models::GetTopLinksResponse, Error<AnalyticsDataServiceGetTopLinksError>> {
478 let p_body_get_top_links_request = get_top_links_request;
480
481 let uri_str = format!("{}/v1/analytics/top-links", configuration.base_path);
482 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
483
484 if let Some(ref user_agent) = configuration.user_agent {
485 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
486 }
487 if let Some(ref token) = configuration.bearer_access_token {
488 req_builder = req_builder.bearer_auth(token.to_owned());
489 };
490 req_builder = req_builder.json(&p_body_get_top_links_request);
491
492 let req = req_builder.build()?;
493 let resp = configuration.client.execute(req).await?;
494
495 let status = resp.status();
496 let content_type = resp
497 .headers()
498 .get("content-type")
499 .and_then(|v| v.to_str().ok())
500 .unwrap_or("application/octet-stream");
501 let content_type = super::ContentType::from(content_type);
502
503 if !status.is_client_error() && !status.is_server_error() {
504 let content = resp.text().await?;
505 match content_type {
506 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
507 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTopLinksResponse`"))),
508 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTopLinksResponse`")))),
509 }
510 } else {
511 let content = resp.text().await?;
512 let entity: Option<AnalyticsDataServiceGetTopLinksError> = serde_json::from_str(&content).ok();
513 Err(Error::ResponseError(ResponseContent { status, content, entity }))
514 }
515}
516
517pub async fn analytics_data_service_get_visitor_trends(configuration: &configuration::Configuration, get_visitor_trends_request: models::GetVisitorTrendsRequest) -> Result<models::GetVisitorTrendsResponse, Error<AnalyticsDataServiceGetVisitorTrendsError>> {
519 let p_body_get_visitor_trends_request = get_visitor_trends_request;
521
522 let uri_str = format!("{}/v1/analytics/visitors", configuration.base_path);
523 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
524
525 if let Some(ref user_agent) = configuration.user_agent {
526 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
527 }
528 if let Some(ref token) = configuration.bearer_access_token {
529 req_builder = req_builder.bearer_auth(token.to_owned());
530 };
531 req_builder = req_builder.json(&p_body_get_visitor_trends_request);
532
533 let req = req_builder.build()?;
534 let resp = configuration.client.execute(req).await?;
535
536 let status = resp.status();
537 let content_type = resp
538 .headers()
539 .get("content-type")
540 .and_then(|v| v.to_str().ok())
541 .unwrap_or("application/octet-stream");
542 let content_type = super::ContentType::from(content_type);
543
544 if !status.is_client_error() && !status.is_server_error() {
545 let content = resp.text().await?;
546 match content_type {
547 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
548 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVisitorTrendsResponse`"))),
549 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetVisitorTrendsResponse`")))),
550 }
551 } else {
552 let content = resp.text().await?;
553 let entity: Option<AnalyticsDataServiceGetVisitorTrendsError> = serde_json::from_str(&content).ok();
554 Err(Error::ResponseError(ResponseContent { status, content, entity }))
555 }
556}
557