use super::super::types::{
DataNotFoundError, InvalidParamsError, RainfallResponse, RateLimitError,
};
#[derive(Debug, Clone, PartialEq)]
pub struct RainfallInput {
pub date: Option<satay_runtime::Date>,
pub pagination_token: Option<String>,
pub x_api_key: Option<String>,
}
impl RainfallInput {
pub fn new() -> Self {
Self {
date: None,
pagination_token: None,
x_api_key: None,
}
}
pub fn date(mut self, date: satay_runtime::Date) -> Self {
self.date = Some(date);
self
}
pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
self.pagination_token = Some(pagination_token.into());
self
}
pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
self.x_api_key = Some(x_api_key.into());
self
}
}
impl Default for RainfallInput {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum RainfallOperationResponse {
Ok(RainfallResponse),
BadRequest(InvalidParamsError),
NotFound(DataNotFoundError),
Status429(RateLimitError),
UnexpectedStatus(http::StatusCode, Vec<u8>),
}
pub fn rainfall_parts(
input: RainfallInput,
) -> Result<satay_runtime::RequestParts<()>, satay_runtime::Error> {
let mut uri = String::with_capacity(9);
uri.push_str("/rainfall");
let mut first_query = true;
if let Some(value) = &input.date {
satay_runtime::append_query_pair(
&mut uri,
&mut first_query,
"date",
&satay_runtime::format_date(value),
);
}
if let Some(value) = &input.pagination_token {
satay_runtime::append_query_pair(
&mut uri,
&mut first_query,
"paginationToken",
value.as_str(),
);
}
let mut headers = http::HeaderMap::new();
if let Some(value) = &input.x_api_key {
satay_runtime::insert_header(&mut headers, "x-api-key", value.as_str())?;
}
Ok(satay_runtime::RequestParts {
method: http::Method::GET,
uri,
headers,
body: (),
})
}