openlark_docs/common/api_endpoints/
base.rs1use super::CatalogEndpoint;
6use openlark_core::api::HttpMethod;
7
8#[derive(Debug, Clone, PartialEq)]
10#[cfg_attr(test, derive(strum_macros::EnumIter))]
11pub enum BaseApiV2 {
12 RoleCreate(String),
14 RoleUpdate(String, String),
16 RoleList(String),
18}
19
20impl BaseApiV2 {
21 pub fn to_url(&self) -> String {
23 match self {
24 BaseApiV2::RoleCreate(app_token) => {
25 format!("/open-apis/base/v2/apps/{app_token}/roles")
26 }
27 BaseApiV2::RoleUpdate(app_token, role_id) => {
28 format!("/open-apis/base/v2/apps/{app_token}/roles/{role_id}")
29 }
30 BaseApiV2::RoleList(app_token) => {
31 format!("/open-apis/base/v2/apps/{app_token}/roles")
32 }
33 }
34 }
35}
36
37impl CatalogEndpoint for BaseApiV2 {
38 fn to_url(&self) -> String {
39 BaseApiV2::to_url(self)
41 }
42
43 fn method(&self) -> HttpMethod {
44 match self {
45 BaseApiV2::RoleCreate(_) => HttpMethod::Post,
46 BaseApiV2::RoleUpdate(_, _) => HttpMethod::Put,
47 BaseApiV2::RoleList(_) => HttpMethod::Get,
48 }
49 }
50
51 }