use super::CatalogEndpoint;
use openlark_core::api::HttpMethod;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(test, derive(strum_macros::EnumIter))]
pub enum BaseApiV2 {
RoleCreate(String),
RoleUpdate(String, String),
RoleList(String),
}
impl BaseApiV2 {
pub fn to_url(&self) -> String {
match self {
BaseApiV2::RoleCreate(app_token) => {
format!("/open-apis/base/v2/apps/{app_token}/roles")
}
BaseApiV2::RoleUpdate(app_token, role_id) => {
format!("/open-apis/base/v2/apps/{app_token}/roles/{role_id}")
}
BaseApiV2::RoleList(app_token) => {
format!("/open-apis/base/v2/apps/{app_token}/roles")
}
}
}
}
impl CatalogEndpoint for BaseApiV2 {
fn to_url(&self) -> String {
BaseApiV2::to_url(self)
}
fn method(&self) -> HttpMethod {
match self {
BaseApiV2::RoleCreate(_) => HttpMethod::Post,
BaseApiV2::RoleUpdate(_, _) => HttpMethod::Put,
BaseApiV2::RoleList(_) => HttpMethod::Get,
}
}
}