diff options
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -159,6 +159,7 @@ struct SyncResCipher { impl SyncResCipher { fn to_entry(&self) -> crate::db::Entry { crate::db::Entry { + id: self.id.clone(), name: self.name.clone(), username: self.login.username.clone(), password: self.login.password.clone(), @@ -310,6 +311,24 @@ impl Client { } } + pub fn remove(&self, access_token: &str, id: &str) -> Result<()> { + let client = reqwest::blocking::Client::new(); + let res = client + .delete(&self.api_url(&format!("/ciphers/{}", id))) + .header("Authorization", format!("Bearer {}", access_token)) + .send() + .context(crate::error::Reqwest)?; + match res.status() { + reqwest::StatusCode::OK => Ok(()), + reqwest::StatusCode::UNAUTHORIZED => { + Err(Error::RequestUnauthorized) + } + _ => Err(Error::RequestFailed { + status: res.status().as_u16(), + }), + } + } + pub fn exchange_refresh_token( &self, refresh_token: &str, |