aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-18 04:24:26 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-18 04:30:04 -0400
commit3765d4f2edc5933f61fd46ab130e366774556cf5 (patch)
tree930ce485993d46dd1e13f00fae00930521c0ef39 /src/api.rs
parentb3c69bf88d973af04433d450a659ef1581d813e2 (diff)
downloadrbw-3765d4f2edc5933f61fd46ab130e366774556cf5.tar.gz
rbw-3765d4f2edc5933f61fd46ab130e366774556cf5.zip
implement remove
Diffstat (limited to 'src/api.rs')
-rw-r--r--src/api.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/api.rs b/src/api.rs
index 9588b4c..f40ff6d 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -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,