use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;
pub struct SearchService<'a> {
scope: Scope<'a>,
}
impl<'a> SearchService<'a> {
pub(crate) fn new(scope: Scope<'a>) -> Self {
Self { scope }
}
pub fn scope(&self) -> &Scope<'a> {
&self.scope
}
pub async fn search(&self, q: &str) -> Result<Page<Vec<Card>>, Error> {
let mut operation = self.scope.operation(&routes::SEARCH_CARDS, &[])?;
operation.query("q", q);
self.scope.client().send_page(operation).await
}
}