From b222695c16bebbc347a7ce2407ce5dc3908b31db Mon Sep 17 00:00:00 2001 From: jane400 Date: Tue, 17 Sep 2024 11:54:36 +0200 Subject: [PATCH] feat: more optional fields in stammdaten --- libpaket/src/stammdaten.rs | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/libpaket/src/stammdaten.rs b/libpaket/src/stammdaten.rs index aaf0239..b275ba0 100644 --- a/libpaket/src/stammdaten.rs +++ b/libpaket/src/stammdaten.rs @@ -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>, + //pub customer_actions: Option, + pub address: CustomerAddress, }