feat: more optional fields in stammdaten

This commit is contained in:
jane400 2024-09-17 11:54:36 +02:00 committed by jane400
parent 5b205ce1e0
commit b222695c16

View file

@ -1,8 +1,8 @@
use reqwest::{header::HeaderMap, Request, RequestBuilder};
use crate::www::authorized_credentials;
use crate::constants::{app_version, linux_android_version};
use crate::common::APIResult;
use crate::constants::okhttp_user_agent;
use crate::www::authorized_credentials;
use crate::{login::DHLIdToken, LibraryResult};
pub struct StammdatenClient {
@ -15,18 +15,19 @@ impl StammdatenClient {
StammdatenClient {
client: reqwest::ClientBuilder::new()
.default_headers(headers())
.user_agent(user_agent())
.user_agent(okhttp_user_agent())
.build()
.unwrap(),
}
}
pub(crate) fn base_request(&self, request_builder: RequestBuilder, dhli: &DHLIdToken) -> Request {
pub(crate) fn base_request(
&self,
request_builder: RequestBuilder,
dhli: &DHLIdToken,
) -> Request {
request_builder
.basic_auth(
authorized_credentials().0,
Some(authorized_credentials().1),
)
.basic_auth(authorized_credentials().0, Some(authorized_credentials().1))
.headers(headers())
.header("cookie", format!("dhli={}", dhli.as_str()))
.build()
@ -68,16 +69,6 @@ impl StammdatenClient {
Err(err) => Err(err.into()),
}
}
}
fn user_agent() -> String {
format!(
"okhttp/4.11.0 Post & DHL/{} ({})",
app_version(),
linux_android_version()
)
}
fn headers() -> HeaderMap {
@ -144,9 +135,13 @@ pub enum CustomerDataService {
}
#[derive(serde::Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CustomerDataFull {
#[serde(flatten)]
pub common: CustomerData,
pub requested_services: Option<Vec<CustomerDataService>>,
//pub customer_actions: Option,
pub address: CustomerAddress,
}