fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;

/// The `Search` operations.
pub struct SearchService<'a> {
    scope: Scope<'a>,
}

impl<'a> SearchService<'a> {
    pub(crate) fn new(scope: Scope<'a>) -> Self {
        Self { scope }
    }

    /// The client and account these operations send through.
    pub fn scope(&self) -> &Scope<'a> {
        &self.scope
    }

    /// `SearchCards` — `GET /{accountId}/search.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    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
    }
}