From 840f53b84206f9efe0a5cdea3414c472908a22e4 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 18 Apr 2020 01:30:32 -0400 Subject: implement add command --- src/actions.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/actions.rs') diff --git a/src/actions.rs b/src/actions.rs index c942f32..07cf6ba 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -52,9 +52,26 @@ pub async fn sync( client.sync(access_token).await } -pub async fn exchange_refresh_token(refresh_token: &str) -> Result { +pub fn add(access_token: &str, cipher: &crate::api::Cipher) -> Result<()> { + let config = crate::config::Config::load()?; + let client = + crate::api::Client::new(&config.base_url(), &config.identity_url()); + client.add(access_token, cipher)?; + Ok(()) +} + +pub fn exchange_refresh_token(refresh_token: &str) -> Result { + let config = crate::config::Config::load()?; + let client = + crate::api::Client::new(&config.base_url(), &config.identity_url()); + client.exchange_refresh_token(refresh_token) +} + +pub async fn exchange_refresh_token_async( + refresh_token: &str, +) -> Result { let config = crate::config::Config::load_async().await?; let client = crate::api::Client::new(&config.base_url(), &config.identity_url()); - client.exchange_refresh_token(refresh_token).await + client.exchange_refresh_token_async(refresh_token).await } -- cgit v1.2.3-54-g00ecf