aboutsummaryrefslogtreecommitdiffstats
path: root/crates/rocie-client/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rocie-client/src')
-rw-r--r--crates/rocie-client/src/apis/api_get_product_api.rs91
1 files changed, 90 insertions, 1 deletions
diff --git a/crates/rocie-client/src/apis/api_get_product_api.rs b/crates/rocie-client/src/apis/api_get_product_api.rs
index 481084b..2e18d8a 100644
--- a/crates/rocie-client/src/apis/api_get_product_api.rs
+++ b/crates/rocie-client/src/apis/api_get_product_api.rs
@@ -24,6 +24,23 @@ pub enum ProductByIdError {
UnknownValue(serde_json::Value),
}
+/// struct for typed errors of method [`product_by_name`]
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum ProductByNameError {
+ Status404(),
+ Status500(String),
+ UnknownValue(serde_json::Value),
+}
+
+/// struct for typed errors of method [`product_suggestion_by_name`]
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum ProductSuggestionByNameError {
+ Status500(String),
+ UnknownValue(serde_json::Value),
+}
+
/// struct for typed errors of method [`products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
@@ -37,7 +54,7 @@ pub async fn product_by_id(configuration: &configuration::Configuration, id: mod
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
- let uri_str = format!("{}/product/{id}", configuration.base_path, id=p_id.to_string());
+ let uri_str = format!("{}/product/by-id/{id}", configuration.base_path, id=p_id.to_string());
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
@@ -69,6 +86,78 @@ pub async fn product_by_id(configuration: &configuration::Configuration, id: mod
}
}
+pub async fn product_by_name(configuration: &configuration::Configuration, name: &str) -> Result<models::Product, Error<ProductByNameError>> {
+ // add a prefix to parameters to efficiently prevent name collisions
+ let p_name = name;
+
+ let uri_str = format!("{}/product/by-name/{name}", configuration.base_path, name=crate::apis::urlencode(p_name));
+ let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+
+ let req = req_builder.build()?;
+ let resp = configuration.client.execute(req).await?;
+
+ let status = resp.status();
+ let content_type = resp
+ .headers()
+ .get("content-type")
+ .and_then(|v| v.to_str().ok())
+ .unwrap_or("application/octet-stream");
+ let content_type = super::ContentType::from(content_type);
+
+ if !status.is_client_error() && !status.is_server_error() {
+ let content = resp.text().await?;
+ match content_type {
+ ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
+ ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Product`"))),
+ ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Product`")))),
+ }
+ } else {
+ let content = resp.text().await?;
+ let entity: Option<ProductByNameError> = serde_json::from_str(&content).ok();
+ Err(Error::ResponseError(ResponseContent { status, content, entity }))
+ }
+}
+
+pub async fn product_suggestion_by_name(configuration: &configuration::Configuration, name: &str) -> Result<Vec<models::Product>, Error<ProductSuggestionByNameError>> {
+ // add a prefix to parameters to efficiently prevent name collisions
+ let p_name = name;
+
+ let uri_str = format!("{}/product/by-part-name/{name}", configuration.base_path, name=crate::apis::urlencode(p_name));
+ let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+
+ let req = req_builder.build()?;
+ let resp = configuration.client.execute(req).await?;
+
+ let status = resp.status();
+ let content_type = resp
+ .headers()
+ .get("content-type")
+ .and_then(|v| v.to_str().ok())
+ .unwrap_or("application/octet-stream");
+ let content_type = super::ContentType::from(content_type);
+
+ if !status.is_client_error() && !status.is_server_error() {
+ let content = resp.text().await?;
+ match content_type {
+ ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
+ ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Product&gt;`"))),
+ ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Product&gt;`")))),
+ }
+ } else {
+ let content = resp.text().await?;
+ let entity: Option<ProductSuggestionByNameError> = serde_json::from_str(&content).ok();
+ Err(Error::ResponseError(ResponseContent { status, content, entity }))
+ }
+}
+
pub async fn products(configuration: &configuration::Configuration, ) -> Result<Vec<models::Product>, Error<ProductsError>> {
let uri_str = format!("{}/products/", configuration.base_path);