use crate::resourcesearch::models::SearchDetails;
pub struct SearchResourcesRequestRequired {
pub search_details: SearchDetails,
}
#[derive(Debug, Clone)]
pub struct SearchResourcesRequest {
pub search_details: SearchDetails,
pub limit: Option<u32>,
pub page: Option<String>,
pub tenant_id: Option<String>,
pub opc_request_id: Option<String>,
}
impl SearchResourcesRequest {
pub fn new(required: SearchResourcesRequestRequired) -> Self {
Self {
search_details: required.search_details,
limit: None,
page: None,
tenant_id: None,
opc_request_id: None,
}
}
pub fn set_search_details(mut self, search_details: SearchDetails) -> Self {
self.search_details = search_details;
self
}
pub fn set_limit(mut self, limit: Option<u32>) -> Self {
self.limit = limit;
self
}
pub fn set_page(mut self, page: Option<String>) -> Self {
self.page = page;
self
}
pub fn set_tenant_id(mut self, tenant_id: Option<String>) -> Self {
self.tenant_id = tenant_id;
self
}
pub fn set_opc_request_id(mut self, opc_request_id: Option<String>) -> Self {
self.opc_request_id = opc_request_id;
self
}
pub fn with_limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
pub fn with_page(mut self, page: impl Into<String>) -> Self {
self.page = Some(page.into());
self
}
pub fn with_tenant_id(mut self, tenant_id: impl Into<String>) -> Self {
self.tenant_id = Some(tenant_id.into());
self
}
pub fn with_opc_request_id(mut self, id: impl Into<String>) -> Self {
self.opc_request_id = Some(id.into());
self
}
pub fn to_query_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(limit) = self.limit {
params.push(("limit".to_string(), limit.to_string()));
}
if let Some(ref page) = self.page {
params.push(("page".to_string(), page.clone()));
}
if let Some(ref tenant_id) = self.tenant_id {
params.push(("tenantId".to_string(), tenant_id.clone()));
}
params
}
}