From 188da6c4c170af7093f0a49d0cfbb118d762e07b Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 11 Jul 2021 15:55:48 +0200 Subject: [PATCH] Add association function to urls Signed-off-by: trivernis --- src/models/url.rs | 14 ++++++++++++++ tests/wrapper/test_url.rs | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/models/url.rs b/src/models/url.rs index 71363d0..5e124e3 100644 --- a/src/models/url.rs +++ b/src/models/url.rs @@ -58,4 +58,18 @@ impl Url { pub fn import(&mut self) -> UrlImportBuilder { UrlImportBuilder::new(self.client.clone(), &self.url) } + + /// Associates the url with a list of file hashes + pub async fn associate(&mut self, hashes: Vec) -> Result<()> { + self.client + .associate_urls(vec![self.url.clone()], hashes) + .await + } + + /// Disassociates the url with a list of file hashes + pub async fn disassociate(&mut self, hashes: Vec) -> Result<()> { + self.client + .disassociate_urls(vec![self.url.clone()], hashes) + .await + } } diff --git a/tests/wrapper/test_url.rs b/tests/wrapper/test_url.rs index 89122f4..7df9806 100644 --- a/tests/wrapper/test_url.rs +++ b/tests/wrapper/test_url.rs @@ -23,3 +23,25 @@ async fn it_imports() { .await .unwrap(); } + +#[tokio::test] +async fn it_associates() { + let mut url = get_url().await; + + url.associate(vec![ + "0000000000000000000000000000000000000000000000000000000000000000".to_string(), + ]) + .await + .unwrap(); +} + +#[tokio::test] +async fn it_disassociates() { + let mut url = get_url().await; + + url.disassociate(vec![ + "0000000000000000000000000000000000000000000000000000000000000000".to_string(), + ]) + .await + .unwrap(); +}