fix: libpaket: add more headers to tracking search
This commit is contained in:
parent
ff66184471
commit
d122cfc065
1 changed files with 32 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{login::DHLIdToken, LibraryError, LibraryResult};
|
||||
use crate::{constants::web_user_agent, login::DHLIdToken, LibraryResult};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TrackingParams {
|
||||
|
@ -19,30 +19,38 @@ impl crate::WebClient {
|
|||
&self,
|
||||
params: TrackingParams,
|
||||
ids: Vec<String>,
|
||||
dhli: Option<&DHLIdToken>,
|
||||
dhli: &DHLIdToken,
|
||||
) -> LibraryResult<Vec<Shipment>> {
|
||||
let api_key = crate::www::api_key_header();
|
||||
let res = if let Some(dhli) = dhli {
|
||||
let cookie_value = crate::utils::CookieHeaderValueBuilder::new()
|
||||
.add_dhli(&dhli)
|
||||
.add_dhlcs(&dhli)
|
||||
.build_string();
|
||||
request!(
|
||||
self.web_client,
|
||||
endpoint_data_search,
|
||||
query(&query_parameters_data_search(¶ms, ids)),
|
||||
header(api_key.0, api_key.1),
|
||||
header("cookie", cookie_value),
|
||||
header("x-requested-with", "de.dhl.paket"),
|
||||
header("sec-ch-ua-platform", "\"Android\""),
|
||||
header("sec-ch-ua", r#""Chromium";v="122", "Not(A:Brand";v="24", "Android WebView";v="122""#),
|
||||
header("sec-ch-ua-mobile", "?1"),
|
||||
header("content-type", "application/json"),
|
||||
header("accept", "application/json")
|
||||
)
|
||||
} else {
|
||||
return Err(LibraryError::InvalidArgument("only supported with a logged-in session".to_string()));
|
||||
};
|
||||
let cookie_value = crate::utils::CookieHeaderValueBuilder::new()
|
||||
.add_dhli(&dhli)
|
||||
.add_dhlcs(&dhli)
|
||||
.build_string();
|
||||
|
||||
let res = request!(
|
||||
self.web_client,
|
||||
endpoint_data_search,
|
||||
query(&query_parameters_data_search(¶ms, ids)),
|
||||
header(api_key.0, api_key.1),
|
||||
header("cookie", cookie_value),
|
||||
header("accept-language", "de-DE;q=1.0"),
|
||||
header("x-requested-with", "de.dhl.paket"),
|
||||
header("sec-ch-ua-platform", "\"Android\""),
|
||||
header(
|
||||
"sec-ch-ua",
|
||||
r#""Chromium";v="122", "Not(A:Brand";v="24", "Android WebView";v="122""#
|
||||
),
|
||||
header("sec-ch-ua-mobile", "?1"),
|
||||
header("accept", "application/json"),
|
||||
header("content-type", "application/json"),
|
||||
header(
|
||||
"referer",
|
||||
"https://www.dhl.de/int-static/pdapp/spa/prod/ver5-SPA-VERFOLGEN.html"
|
||||
),
|
||||
header("verfolgen-wg", "0"),
|
||||
header("user-agent", web_user_agent()),
|
||||
headers(crate::www::web_headers())
|
||||
);
|
||||
|
||||
let resp = parse_json_response!(res, Response);
|
||||
resp.into()
|
||||
|
@ -418,7 +426,7 @@ fn query_parameters_data_search(
|
|||
let mut out = vec![
|
||||
("noRedirect".to_string(), "true".to_string()),
|
||||
("cid".to_string(), "app".to_string()),
|
||||
];
|
||||
];
|
||||
|
||||
if let Some(lang) = params.language.as_ref() {
|
||||
out.push(("language".to_string(), lang.clone()));
|
||||
|
|
Loading…
Reference in a new issue