Skip to main content

fizzy_sdk/generated/services/
search.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9/// The `Search` operations.
10pub struct SearchService<'a> {
11    scope: Scope<'a>,
12}
13
14impl<'a> SearchService<'a> {
15    pub(crate) fn new(scope: Scope<'a>) -> Self {
16        Self { scope }
17    }
18
19    /// The client and account these operations send through.
20    pub fn scope(&self) -> &Scope<'a> {
21        &self.scope
22    }
23
24    /// `SearchCards` — `GET /{accountId}/search.json`.
25    ///
26    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
27    ///
28    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
29    pub async fn search(&self, q: &str) -> Result<Page<Vec<Card>>, Error> {
30        let mut operation = self.scope.operation(&routes::SEARCH_CARDS, &[])?;
31        operation.query("q", q);
32        self.scope.client().send_page(operation).await
33    }
34}