use super::GitLabApi;
use crate::network::get::{call, ApiEndpoint};
use crate::network::ForgeApi;
use crate::network::{error, responses::Branch};
use url::Url;
struct BranchesEndpoint {
base_url: Url,
project_id: String,
}
impl ApiEndpoint<Vec<Branch>> for BranchesEndpoint {
fn url(&self) -> Url {
let project_id = &self.project_id;
return self
.base_url
.join(&format!("projects/{project_id}/repository/branches"))
.unwrap();
}
}
pub fn get_branches(api: &GitLabApi, project_id: String) -> Result<Vec<Branch>, error::Error> {
let base_url = api.base_url().clone();
let endpoint: BranchesEndpoint = BranchesEndpoint {
base_url,
project_id,
};
let branches = call(&endpoint)?;
return Ok(branches);
}