use crate::api_core::common::FileIdentifier;
use crate::error::Result;
use crate::Client;
use std::collections::HashMap;
pub struct AddNotesBuilder {
client: Client,
file: FileIdentifier,
notes: HashMap<String, String>,
}
impl AddNotesBuilder {
pub fn new(client: Client, file: FileIdentifier) -> Self {
Self {
client,
file,
notes: HashMap::new(),
}
}
pub fn add_note<S1: ToString, S2: ToString>(mut self, name: S1, note: S2) -> Self {
self.notes.insert(name.to_string(), note.to_string());
self
}
pub fn add_notes<I: IntoIterator<Item = (S1, S2)>, S1: ToString, S2: ToString>(
mut self,
notes: I,
) -> Self {
let notes_iter = notes
.into_iter()
.map(|(k, v): (S1, S2)| (k.to_string(), v.to_string()));
self.notes.extend(notes_iter);
self
}
pub async fn run(self) -> Result<()> {
self.client.set_notes(self.file, self.notes).await
}
}