billecta/
projects.rs

1//! # Projects
2//!
3//! Projects are mainly a bookkeeping feature and enabled you to in the bookkeeping mark
4//! invoices to certain project groups. The feature can also be used to group invoice rows for
5//! later searches. The information is not show on the invoices towards the customers.
6//!
7use crate::{Created, EmptyResponse, Project, Projects, Request, RequestBuilder, Uuid};
8
9///Returns the project the associated project number
10pub fn get_a_project(id: Uuid, projectnumber: &str) -> Request<EmptyResponse> {
11    RequestBuilder::new(http::Method::GET, "/v1/projects/project/")
12        .path_param(id)
13        .query_param("projectnumber", projectnumber)
14        .build()
15}
16pub fn update_a_project(body: &Project) -> Request<EmptyResponse> {
17    RequestBuilder::new(http::Method::PUT, "/v1/projects/project")
18        .body(body)
19        .build()
20}
21///Creates a project. CreditorPublicId is required and specifies under
22///which creditor it shall be created since creditors don't share data
23pub fn create_a_project(body: &Project) -> Request<Created> {
24    RequestBuilder::new(http::Method::POST, "/v1/projects/project")
25        .body(body)
26        .build()
27}
28///A project can't be deleted if it used in an invoice (of any kind)
29pub fn delete_a_project(id: Uuid, projectnumber: &str) -> Request<EmptyResponse> {
30    RequestBuilder::new(http::Method::DELETE, "/v1/projects/project/")
31        .path_param(id)
32        .query_param("projectnumber", projectnumber)
33        .build()
34}
35///Get all projects for a creditor
36pub fn get_all_projects(id: Uuid) -> Request<Projects> {
37    RequestBuilder::new(http::Method::GET, "/v1/projects/projects/")
38        .path_param(id)
39        .build()
40}
41///Imports multiple projects. Projects will be match on ProjectNumber for
42///updates or create
43pub fn create_multiple_projects(body: &Projects) -> Request<Created> {
44    RequestBuilder::new(http::Method::POST, "/v1/projects/projects")
45        .body(body)
46        .build()
47}