diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-18 04:24:26 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-18 04:30:04 -0400 |
commit | 3765d4f2edc5933f61fd46ab130e366774556cf5 (patch) | |
tree | 930ce485993d46dd1e13f00fae00930521c0ef39 /src/api.rs | |
parent | b3c69bf88d973af04433d450a659ef1581d813e2 (diff) | |
download | rbw-3765d4f2edc5933f61fd46ab130e366774556cf5.tar.gz rbw-3765d4f2edc5933f61fd46ab130e366774556cf5.zip |
implement remove
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, |