benchling/request/
list_dropdowns.rs

1use serde_json::json;
2use crate::model::*;
3use crate::BenchlingClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7pub struct ListDropdownsRequest<'a> {
8    pub(crate) client: &'a BenchlingClient,
9    pub next_token: Option<String>,
10    pub page_size: Option<i64>,
11}
12impl<'a> ListDropdownsRequest<'a> {
13    pub async fn send(self) -> anyhow::Result<DropdownSummariesPaginatedList> {
14        let mut r = self.client.client.get("/dropdowns");
15        if let Some(ref unwrapped) = self.next_token {
16            r = r.push_query("nextToken", &unwrapped.to_string());
17        }
18        if let Some(ref unwrapped) = self.page_size {
19            r = r.push_query("pageSize", &unwrapped.to_string());
20        }
21        r = self.client.authenticate(r);
22        let res = r.send().await.unwrap().error_for_status();
23        match res {
24            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
25            Err(res) => {
26                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
27                Err(anyhow::anyhow!("{:?}", text))
28            }
29        }
30    }
31    pub fn next_token(mut self, next_token: &str) -> Self {
32        self.next_token = Some(next_token.to_owned());
33        self
34    }
35    pub fn page_size(mut self, page_size: i64) -> Self {
36        self.page_size = Some(page_size);
37        self
38    }
39}