billecta 1.14.0

Generated Billecta API
Documentation
//! # Products
//!
//!
use crate::{Created, EmptyResponse, Product, ProductsTemplate, Request, RequestBuilder, Uuid};

///Returns the associated product. Note that the values on the product
///should only be considered as a template (except for the bookkeeping
///accounts). When creating an invoice, you must set the specific values
///for that invoice record/row.
pub fn get_a_product(id: Uuid) -> Request<Product> {
    RequestBuilder::new(http::Method::GET, "/v1/products/product/")
        .path_param(id)
        .build()
}
///Note that ProductPublicId must be set when updating a product. It is
///used to identify which product to update. CreditorPublicId specifies
///under which creditor it shall be created since creditors don't share
///data
pub fn update_a_product(body: &Product) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/products/product")
        .body(body)
        .build()
}
///Creates a product. Note that ProductPublicId are generated by Billecta
///API and can't be set through the API and should be omitted when
///creating. CreditorPublicId specifies under which creditor it shall be
///created since creditors don't share data
pub fn create_a_product(body: &Product) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/products/product")
        .body(body)
        .build()
}
///A product can't be deleted if it used in an invoice (of any kind)
pub fn delete_a_product(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/products/product/")
        .path_param(id)
        .build()
}
///Get a single product by its article number
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()
}
///Get a single product by its product description
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()
}
///Get one or more products by external id
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()
}
///Get all products for a creditor
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()
}
///Imports multiple products. If product has ProductPublicId set it will
///update corresponding product. If ProductPublicId is not set the
///product will be created
pub fn create_multiple_products(body: &Vec<Product>) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/products/products")
        .body(body)
        .build()
}
///Get products by its external id. An external id is a field on the
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()
}