fix: tracking: parse rate limited response
Technically NetworkFetch isn't intended for this. /shrug for now
This commit is contained in:
parent
290faff5c2
commit
609fc65816
1 changed files with 14 additions and 10 deletions
|
@ -44,7 +44,7 @@ impl crate::WebClient {
|
||||||
};
|
};
|
||||||
|
|
||||||
let resp = parse_json_response!(res, Response);
|
let resp = parse_json_response!(res, Response);
|
||||||
Ok(resp.into())
|
resp.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn tracking_shipment(
|
pub async fn tracking_shipment(
|
||||||
|
@ -62,7 +62,7 @@ impl crate::WebClient {
|
||||||
);
|
);
|
||||||
|
|
||||||
let resp = parse_json_response!(res, Response);
|
let resp = parse_json_response!(res, Response);
|
||||||
Ok(resp.into())
|
resp.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ struct Sendung {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct Response {
|
struct Response {
|
||||||
sendungen: Vec<Sendung>,
|
sendungen: Option<Vec<Sendung>>,
|
||||||
// TODO: parse RECEIVE_MERGED_SHIPMENTS, what is that?
|
// TODO: parse RECEIVE_MERGED_SHIPMENTS, what is that?
|
||||||
//merged_anonymous_shipment_list_ids: Option<Vec<()>>,
|
//merged_anonymous_shipment_list_ids: Option<Vec<()>>,
|
||||||
is_rate_limited: bool,
|
is_rate_limited: bool,
|
||||||
|
@ -313,7 +313,7 @@ pub struct Shipment {
|
||||||
pub needs_plz: bool,
|
pub needs_plz: bool,
|
||||||
|
|
||||||
pub quelle: SendungsQuelle,
|
pub quelle: SendungsQuelle,
|
||||||
|
|
||||||
// probably not optional
|
// probably not optional
|
||||||
pub international: Option<bool>,
|
pub international: Option<bool>,
|
||||||
// probably not optional
|
// probably not optional
|
||||||
|
@ -388,15 +388,19 @@ impl From<Sendung> for Shipment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Response> for Vec<Shipment> {
|
impl From<Response> for LibraryResult<Vec<Shipment>> {
|
||||||
fn from(value: Response) -> Self {
|
fn from(value: Response) -> Self {
|
||||||
let mut arr = Vec::new();
|
if value.is_rate_limited {
|
||||||
|
Err(crate::LibraryError::NetworkFetch)
|
||||||
|
} else {
|
||||||
|
let mut arr = Vec::new();
|
||||||
|
|
||||||
for item in value.sendungen {
|
for item in value.sendungen.unwrap() {
|
||||||
arr.push(item.into());
|
arr.push(item.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
arr
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue