Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
Dominic Grimm | fdb385c5c6 | ||
Dominic Grimm | 15af617614 | ||
Dominic Grimm | 92cd3ccf97 |
31
src/lib.rs
31
src/lib.rs
|
@ -696,6 +696,37 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn last_import_time(&self) -> Result<chrono::NaiveDateTime> {
|
||||||
|
let resp: RpcResponse<i64> = reqwest::Client::new()
|
||||||
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
|
.header(
|
||||||
|
reqwest::header::COOKIE,
|
||||||
|
self.session.as_ref().context("Not logged in")?,
|
||||||
|
)
|
||||||
|
.json(&json!({
|
||||||
|
"id": "ID",
|
||||||
|
"method": "getLatestImportTime",
|
||||||
|
"jsonrpc": "2.0"
|
||||||
|
}))
|
||||||
|
.send()
|
||||||
|
.await?
|
||||||
|
.json()
|
||||||
|
.await?;
|
||||||
|
if let Some(e) = resp.error {
|
||||||
|
bail!("RPC error: {:?}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(x) = resp.result {
|
||||||
|
Ok(chrono::NaiveDateTime::from_timestamp_millis(x)
|
||||||
|
.context("Could not convert Unix timestamp to NaiveDateTime")?)
|
||||||
|
} else {
|
||||||
|
bail!("RPC result is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn construct_bearer(auth: &str) -> String {
|
pub fn construct_bearer(auth: &str) -> String {
|
||||||
format!("Bearer {}", auth)
|
format!("Bearer {}", auth)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue