open_lark/service/contact/v3/
job_level.rs1use crate::{
2 core::{
3 api_req::ApiRequest, api_resp::ApiResponseTrait, config::Config,
4 constants::AccessTokenType, endpoints::EndpointBuilder, http::Transport,
5 },
6 service::contact::models::*,
7};
8use serde::{Deserialize, Serialize};
9
10pub struct JobLevelService {
12 config: Config,
13}
14
15impl JobLevelService {
16 pub fn new(config: Config) -> Self {
17 Self { config }
18 }
19
20 pub async fn create(
22 &self,
23 req: &CreateJobLevelRequest,
24 ) -> crate::core::SDKResult<CreateJobLevelResponse> {
25 let api_req = ApiRequest {
26 http_method: reqwest::Method::POST,
27 api_path: crate::core::endpoints::contact::CONTACT_V3_JOB_LEVELS.to_string(),
28 supported_access_token_types: vec![AccessTokenType::Tenant],
29 body: serde_json::to_vec(req)?,
30 ..Default::default()
31 };
32
33 let resp =
34 Transport::<CreateJobLevelResponse>::request(api_req, &self.config, None).await?;
35 Ok(resp.data.unwrap_or_default())
36 }
37
38 pub async fn update(
40 &self,
41 job_level_id: &str,
42 req: &UpdateJobLevelRequest,
43 ) -> crate::core::SDKResult<UpdateJobLevelResponse> {
44 let api_req = ApiRequest {
45 http_method: reqwest::Method::PUT,
46 api_path: EndpointBuilder::replace_param(
47 crate::core::endpoints::contact::CONTACT_V3_JOB_LEVEL_GET,
48 "job_level_id",
49 job_level_id,
50 ),
51 supported_access_token_types: vec![AccessTokenType::Tenant],
52 body: serde_json::to_vec(req)?,
53 ..Default::default()
54 };
55
56 let resp =
57 Transport::<UpdateJobLevelResponse>::request(api_req, &self.config, None).await?;
58 Ok(resp.data.unwrap_or_default())
59 }
60
61 pub async fn get(&self, job_level_id: &str) -> crate::core::SDKResult<GetJobLevelResponse> {
63 let api_req = ApiRequest {
64 http_method: reqwest::Method::GET,
65 api_path: EndpointBuilder::replace_param(
66 crate::core::endpoints::contact::CONTACT_V3_JOB_LEVEL_GET,
67 "job_level_id",
68 job_level_id,
69 ),
70 supported_access_token_types: vec![AccessTokenType::Tenant],
71 body: Vec::new(),
72 ..Default::default()
73 };
74
75 let resp = Transport::<GetJobLevelResponse>::request(api_req, &self.config, None).await?;
76 Ok(resp.data.unwrap_or_default())
77 }
78
79 pub async fn list(
81 &self,
82 _req: &ListJobLevelsRequest,
83 ) -> crate::core::SDKResult<ListJobLevelsResponse> {
84 let api_req = ApiRequest {
85 http_method: reqwest::Method::GET,
86 api_path: crate::core::endpoints::contact::CONTACT_V3_JOB_LEVELS.to_string(),
87 supported_access_token_types: vec![AccessTokenType::Tenant],
88 body: Vec::new(),
89 query_params: std::collections::HashMap::new(),
90 ..Default::default()
91 };
92
93 let resp = Transport::<ListJobLevelsResponse>::request(api_req, &self.config, None).await?;
94 Ok(resp.data.unwrap_or_default())
95 }
96
97 pub async fn delete(
99 &self,
100 job_level_id: &str,
101 ) -> crate::core::SDKResult<DeleteJobLevelResponse> {
102 let api_req = ApiRequest {
103 http_method: reqwest::Method::DELETE,
104 api_path: EndpointBuilder::replace_param(
105 crate::core::endpoints::contact::CONTACT_V3_JOB_LEVEL_GET,
106 "job_level_id",
107 job_level_id,
108 ),
109 supported_access_token_types: vec![AccessTokenType::Tenant],
110 body: Vec::new(),
111 ..Default::default()
112 };
113
114 let resp =
115 Transport::<DeleteJobLevelResponse>::request(api_req, &self.config, None).await?;
116 Ok(resp.data.unwrap_or_default())
117 }
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct CreateJobLevelRequest {
122 pub job_level: JobLevel,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize, Default)]
126pub struct CreateJobLevelResponse {
127 pub job_level: JobLevel,
128}
129
130impl ApiResponseTrait for CreateJobLevelResponse {
131 fn data_format() -> crate::core::api_resp::ResponseFormat {
132 crate::core::api_resp::ResponseFormat::Data
133 }
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
137pub struct UpdateJobLevelRequest {
138 pub job_level: JobLevel,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize, Default)]
142pub struct UpdateJobLevelResponse {
143 pub job_level: JobLevel,
144}
145
146impl ApiResponseTrait for UpdateJobLevelResponse {
147 fn data_format() -> crate::core::api_resp::ResponseFormat {
148 crate::core::api_resp::ResponseFormat::Data
149 }
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize, Default)]
153pub struct GetJobLevelResponse {
154 pub job_level: JobLevel,
155}
156
157impl ApiResponseTrait for GetJobLevelResponse {
158 fn data_format() -> crate::core::api_resp::ResponseFormat {
159 crate::core::api_resp::ResponseFormat::Data
160 }
161}
162
163#[derive(Debug, Clone, Default, Serialize, Deserialize)]
164pub struct ListJobLevelsRequest {
165 #[serde(skip_serializing_if = "Option::is_none")]
166 pub page_size: Option<i32>,
167 #[serde(skip_serializing_if = "Option::is_none")]
168 pub page_token: Option<String>,
169}
170
171#[derive(Debug, Clone, Serialize, Deserialize, Default)]
172pub struct ListJobLevelsResponse {
173 pub items: Vec<JobLevel>,
174 #[serde(skip_serializing_if = "Option::is_none")]
175 pub has_more: Option<bool>,
176 #[serde(skip_serializing_if = "Option::is_none")]
177 pub page_token: Option<String>,
178}
179
180impl ApiResponseTrait for ListJobLevelsResponse {
181 fn data_format() -> crate::core::api_resp::ResponseFormat {
182 crate::core::api_resp::ResponseFormat::Data
183 }
184}
185
186#[derive(Debug, Clone, Serialize, Deserialize, Default)]
187pub struct DeleteJobLevelResponse {}
188
189impl ApiResponseTrait for DeleteJobLevelResponse {
190 fn data_format() -> crate::core::api_resp::ResponseFormat {
191 crate::core::api_resp::ResponseFormat::Data
192 }
193}