chore: briefankuendigung: adjust to dhl changes
This commit is contained in:
parent
20dd4fc807
commit
c07a164903
1 changed files with 14 additions and 7 deletions
|
@ -1,10 +1,10 @@
|
||||||
pub use super::Advice;
|
pub use super::Advice;
|
||||||
use super::AdvicesResponse;
|
use super::AdvicesResponse;
|
||||||
|
|
||||||
use reqwest::header::HeaderMap;
|
|
||||||
use serde::Serialize;
|
|
||||||
use crate::constants::webview_user_agent;
|
use crate::constants::webview_user_agent;
|
||||||
use crate::LibraryResult;
|
use crate::LibraryResult;
|
||||||
|
use reqwest::header::HeaderMap;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
pub struct AdviceClient {
|
pub struct AdviceClient {
|
||||||
client: reqwest::Client,
|
client: reqwest::Client,
|
||||||
|
@ -27,7 +27,10 @@ impl AdviceClient {
|
||||||
pub async fn access_token<'t>(&self, advices: &AdvicesResponse) -> LibraryResult<UatToken> {
|
pub async fn access_token<'t>(&self, advices: &AdvicesResponse) -> LibraryResult<UatToken> {
|
||||||
mini_assert_inval!(advices.has_any_advices());
|
mini_assert_inval!(advices.has_any_advices());
|
||||||
|
|
||||||
mini_assert_api_eq!(advices.access_token_url.as_ref().unwrap().as_str(), endpoint_access_tokens());
|
mini_assert_api_eq!(
|
||||||
|
advices.access_token_url.as_ref().unwrap().as_str(),
|
||||||
|
endpoint_access_tokens()
|
||||||
|
);
|
||||||
|
|
||||||
let req = self
|
let req = self
|
||||||
.client
|
.client
|
||||||
|
@ -46,10 +49,13 @@ impl AdviceClient {
|
||||||
let res = res.unwrap();
|
let res = res.unwrap();
|
||||||
|
|
||||||
for cookie in res.cookies() {
|
for cookie in res.cookies() {
|
||||||
if cookie.name() == "UAT" {
|
println!("UAT: cookie: {:?}={:?}", cookie.name(), cookie.value());
|
||||||
|
if cookie.name() == "AccessToken" {
|
||||||
return Ok(UatToken(cookie.value().to_string()));
|
return Ok(UatToken(cookie.value().to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("UAT: headers: {:?}", res.headers());
|
||||||
|
println!("UAT: text: {:?}", res.text().await);
|
||||||
// FIXME: Parse errors here better (checking if we're unauthorized,...)
|
// FIXME: Parse errors here better (checking if we're unauthorized,...)
|
||||||
panic!("NO UAT Token in access_token");
|
panic!("NO UAT Token in access_token");
|
||||||
}
|
}
|
||||||
|
@ -86,9 +92,10 @@ impl AdviceClient {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let req = self.client
|
let req = self
|
||||||
|
.client
|
||||||
.get(&advice.image_url)
|
.get(&advice.image_url)
|
||||||
.header("Cookie", format!("UAT={}", uat.0))
|
.header("Cookie", format!("AccessToken={}", uat.0))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let res = self.client.execute(req).await;
|
let res = self.client.execute(req).await;
|
||||||
|
@ -150,5 +157,5 @@ fn headers() -> HeaderMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn endpoint_access_tokens() -> &'static str {
|
pub fn endpoint_access_tokens() -> &'static str {
|
||||||
"https://briefankuendigung.dhl.de/pdapp-web/access-tokens"
|
"https://briefankuendigung.enplify.dhl.de/pdapp-web/access-tokens"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue