Addded update methods to backend api clients

This commit is contained in:
Franklin 2023-04-25 06:36:09 -04:00
parent a4255eb4fd
commit 6d577ddb9f

View File

@ -1,7 +1,7 @@
use std::collections::HashSet;
use jl_types::{
domain::{agent::Agent, contact::Contact, count::Count, location::Location, project::Project},
domain::{agent::Agent, contact::Contact, count::Count, location::Location, project::Project, unit::Unit},
dto::{
filters::Filter,
item::Item,
@ -9,7 +9,7 @@ use jl_types::{
payloads::{
contact::ContactPayload,
location::NewLocationPayload,
project::{NewProjectPayload, UpdateProjectPayload},
project::{NewProjectPayload, UpdateProjectPayload}, unit::UpdateUnitPayload, agent::UpdateAgentPayload,
},
project_card::ProjectCardDto,
},
@ -197,6 +197,18 @@ pub async fn create_location(location: NewLocationPayload) -> Result<Location, e
)
.await
}
pub async fn update_agent(agent: UpdateAgentPayload) -> Result<Agent, err::Error> {
perform_request_without_client(
BASE_URL.into(),
Method::PUT,
format!("admin/agent"),
Some(agent),
200,
Vec::new(),
None,
)
.await
}
pub async fn update_project(project: UpdateProjectPayload) -> Result<Project, err::Error> {
perform_request_without_client(
@ -211,6 +223,19 @@ pub async fn update_project(project: UpdateProjectPayload) -> Result<Project, er
.await
}
pub async fn update_unit(unit: UpdateUnitPayload) -> Result<Unit, err::Error> {
perform_request_without_client(
BASE_URL.into(),
Method::PUT,
format!("admin/unit"),
Some(unit),
200,
Vec::new(),
None,
)
.await
}
pub async fn delete_project(project_id: &Uuid) -> Result<(), err::Error> {
perform_request_without_client::<String, ()>(
BASE_URL.into(),