use crate::{Created, EmptyResponse, Product, ProductsTemplate, Request, RequestBuilder, Uuid};
pub fn get_a_product(id: Uuid) -> Request<Product> {
RequestBuilder::new(http::Method::GET, "/v1/products/product/")
.path_param(id)
.build()
}
pub fn update_a_product(body: &Product) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::PUT, "/v1/products/product")
.body(body)
.build()
}
pub fn create_a_product(body: &Product) -> Request<Created> {
RequestBuilder::new(http::Method::POST, "/v1/products/product")
.body(body)
.build()
}
pub fn delete_a_product(id: Uuid) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::DELETE, "/v1/products/product/")
.path_param(id)
.build()
}
pub fn get_product_by_article_number(id: Uuid, articlenumber: &str) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::GET, "/v1/products/productbyarticlenumber/")
.path_param(id)
.query_param("articlenumber", articlenumber)
.build()
}
pub fn get_product_by_product_description(id: Uuid, description: &str) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::GET, "/v1/products/productbydescription/")
.path_param(id)
.query_param("description", description)
.build()
}
pub fn get_products_by_external_id(id: Uuid, externalid: &str) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::GET, "/v1/products/productbyexternalid/")
.path_param(id)
.query_param("externalid", externalid)
.build()
}
pub fn get_all_products(
id: Uuid,
offset: Option<i32>,
limit: Option<i32>,
sortingfield: Option<&str>,
asc: Option<bool>,
) -> Request<Vec<Product>> {
RequestBuilder::new(http::Method::GET, "/v1/products/products/")
.path_param(id)
.query_param_opt("offset", offset)
.query_param_opt("limit", limit)
.query_param_opt("sortingfield", sortingfield)
.query_param_opt("asc", asc)
.build()
}
pub fn create_multiple_products(body: &Vec<Product>) -> Request<Created> {
RequestBuilder::new(http::Method::POST, "/v1/products/products")
.body(body)
.build()
}
pub fn get_products_by_product_external_id(
id: Uuid,
productexternalid: &str,
offset: Option<i32>,
limit: Option<i32>,
sortingfield: Option<&str>,
asc: Option<bool>,
) -> Request<Vec<Product>> {
RequestBuilder::new(http::Method::GET, "/v1/products/productsbyexternalid/")
.path_param(id)
.query_param("productexternalid", productexternalid)
.query_param_opt("offset", offset)
.query_param_opt("limit", limit)
.query_param_opt("sortingfield", sortingfield)
.query_param_opt("asc", asc)
.build()
}
pub fn get_product_template(id: Uuid) -> Request<ProductsTemplate> {
RequestBuilder::new(http::Method::GET, "/v1/products/productstemplate/")
.path_param(id)
.build()
}
pub fn create_update_a_product(body: &ProductsTemplate) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::PUT, "/v1/products/productstemplate")
.body(body)
.build()
}