use crate::client_db::ClientDb; use crate::error::Result; use crate::models::{CookieJar, CookieJarIden}; use crate::util::UpdateSource; impl<'a> ClientDb<'a> { pub fn get_cookie_jar(&self, id: &str) -> Result { self.find_one(CookieJarIden::Id, id) } pub fn list_cookie_jars(&self, workspace_id: &str) -> Result> { let mut cookie_jars = self.find_many(CookieJarIden::WorkspaceId, workspace_id, None)?; if cookie_jars.is_empty() { let jar = CookieJar { name: "Default".to_string(), workspace_id: workspace_id.to_string(), ..Default::default() }; cookie_jars.push(self.upsert_cookie_jar(&jar, &UpdateSource::Background)?); } Ok(cookie_jars) } pub fn delete_cookie_jar( &self, cookie_jar: &CookieJar, source: &UpdateSource, ) -> Result { self.delete(cookie_jar, source) } pub fn delete_cookie_jar_by_id(&self, id: &str, source: &UpdateSource) -> Result { let cookie_jar = self.get_cookie_jar(id)?; self.delete_cookie_jar(&cookie_jar, source) } pub fn upsert_cookie_jar( &self, cookie_jar: &CookieJar, source: &UpdateSource, ) -> Result { self.upsert(cookie_jar, source) } }