1#![allow(
3 clippy::doc_markdown,
4 clippy::missing_errors_doc,
5 clippy::must_use_candidate,
6 clippy::needless_pass_by_value,
7 clippy::return_self_not_must_use,
8 clippy::single_match_else
9)]
10
11use super::super::types::{
12 DataNotFoundError, InvalidParamsError, RainfallResponse, RateLimitError,
13};
14#[derive(Debug, Clone, PartialEq)]
24pub struct RainfallInput {
25 pub date: Option<satay_runtime::Date>,
27 pub pagination_token: Option<String>,
29 pub x_api_key: Option<String>,
31}
32impl RainfallInput {
33 pub fn new() -> Self {
34 Self {
35 date: None,
36 pagination_token: None,
37 x_api_key: None,
38 }
39 }
40 pub fn date(mut self, date: satay_runtime::Date) -> Self {
41 self.date = Some(date);
42 self
43 }
44 pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
45 self.pagination_token = Some(pagination_token.into());
46 self
47 }
48 pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
49 self.x_api_key = Some(x_api_key.into());
50 self
51 }
52}
53impl Default for RainfallInput {
54 fn default() -> Self {
55 Self::new()
56 }
57}
58#[derive(Debug, Clone, PartialEq)]
68pub enum RainfallOperationResponse {
69 Ok(RainfallResponse),
71 BadRequest(InvalidParamsError),
73 NotFound(DataNotFoundError),
75 Status429(RateLimitError),
77 UnexpectedStatus(http::StatusCode, Vec<u8>),
78}
79pub fn rainfall_parts(
89 input: RainfallInput,
90) -> Result<satay_runtime::RequestParts<()>, satay_runtime::Error> {
91 let mut uri = String::with_capacity(9);
92 uri.push_str("/rainfall");
93 let mut first_query = true;
94 if let Some(value) = &input.date {
95 satay_runtime::append_query_pair(
96 &mut uri,
97 &mut first_query,
98 "date",
99 &satay_runtime::format_date(value),
100 );
101 }
102 if let Some(value) = &input.pagination_token {
103 satay_runtime::append_query_pair(
104 &mut uri,
105 &mut first_query,
106 "paginationToken",
107 value.as_str(),
108 );
109 }
110 let mut headers = http::HeaderMap::new();
111 if let Some(value) = &input.x_api_key {
112 satay_runtime::insert_header(&mut headers, "x-api-key", value.as_str())?;
113 }
114 Ok(satay_runtime::RequestParts {
115 method: http::Method::GET,
116 uri,
117 headers,
118 body: (),
119 })
120}