1 use {
2 crate::url_builder::{build_project_url, build_project_url_with_id},
3 reqwest::Client,
4 smbcloud_model::{error_codes::ErrorResponse, project::Project},
5 smbcloud_network::{environment::Environment, network::request},
6 smbcloud_networking::{constants::SMB_USER_AGENT, smb_client::SmbClient},
7 };
8
9 pub async fn get_project(
10 env: Environment,
11 client: (&SmbClient, &str),
12 access_token: String,
13 id: String,
14 ) -> Result<Project, ErrorResponse> {
15 let builder: reqwest::RequestBuilder = Client::new()
16 .get(build_project_url_with_id(env, client, id))
17 .header("Authorization", access_token)
18 .header("User-agent", SMB_USER_AGENT);
19 request(builder).await
20 }
21
22 pub async fn get_projects(
23 env: Environment,
24 client: (&SmbClient, &str),
25 access_token: String,
26 ) -> Result<Vec<Project>, ErrorResponse> {
27 let builder = Client::new()
28 .get(build_project_url(env, client))
29 .header("Authorization", access_token)
30 .header("User-agent", SMB_USER_AGENT);
31 request(builder).await
32 }