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
1 changed files with 27 additions and 2 deletions

View File

@ -1,7 +1,7 @@
use std::collections::HashSet; use std::collections::HashSet;
use jl_types::{ 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::{ dto::{
filters::Filter, filters::Filter,
item::Item, item::Item,
@ -9,7 +9,7 @@ use jl_types::{
payloads::{ payloads::{
contact::ContactPayload, contact::ContactPayload,
location::NewLocationPayload, location::NewLocationPayload,
project::{NewProjectPayload, UpdateProjectPayload}, project::{NewProjectPayload, UpdateProjectPayload}, unit::UpdateUnitPayload, agent::UpdateAgentPayload,
}, },
project_card::ProjectCardDto, project_card::ProjectCardDto,
}, },
@ -197,6 +197,18 @@ pub async fn create_location(location: NewLocationPayload) -> Result<Location, e
) )
.await .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> { pub async fn update_project(project: UpdateProjectPayload) -> Result<Project, err::Error> {
perform_request_without_client( perform_request_without_client(
@ -211,6 +223,19 @@ pub async fn update_project(project: UpdateProjectPayload) -> Result<Project, er
.await .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> { pub async fn delete_project(project_id: &Uuid) -> Result<(), err::Error> {
perform_request_without_client::<String, ()>( perform_request_without_client::<String, ()>(
BASE_URL.into(), BASE_URL.into(),