zsgf_client/apis/
wechat_api.rs

1/*
2 * 全部  API 文档
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`wechat_decrypt`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum WechatDecryptError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`wechat_generate_scheme`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum WechatGenerateSchemeError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`wechat_js_code2_session`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum WechatJsCode2SessionError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`wechat_js_config`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum WechatJsConfigError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`wechat_subscribe_msg`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum WechatSubscribeMsgError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`wechat_subscribe_send`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum WechatSubscribeSendError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`wechat_url_link_generate`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum WechatUrlLinkGenerateError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`wechat_user_info`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum WechatUserInfoError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`wechat_wxa_code_get`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum WechatWxaCodeGetError {
78    Status400(std::path::PathBuf),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`wechat_wxa_code_get_unlimited`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum WechatWxaCodeGetUnlimitedError {
86    Status400(std::path::PathBuf),
87    UnknownValue(serde_json::Value),
88}
89
90
91/// 解密小程序加密数据
92pub async fn wechat_decrypt(configuration: &configuration::Configuration, app_key: &str, encrypted_data: Option<&str>, iv: Option<&str>, session_key: Option<&str>) -> Result<models::StringApiResponse, Error<WechatDecryptError>> {
93    // add a prefix to parameters to efficiently prevent name collisions
94    let p_app_key = app_key;
95    let p_encrypted_data = encrypted_data;
96    let p_iv = iv;
97    let p_session_key = session_key;
98
99    let uri_str = format!("{}/Wechat/{appKey}/Decrypt", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
101
102    if let Some(ref param_value) = p_encrypted_data {
103        req_builder = req_builder.query(&[("encryptedData", &param_value.to_string())]);
104    }
105    if let Some(ref param_value) = p_iv {
106        req_builder = req_builder.query(&[("iv", &param_value.to_string())]);
107    }
108    if let Some(ref param_value) = p_session_key {
109        req_builder = req_builder.query(&[("sessionKey", &param_value.to_string())]);
110    }
111    if let Some(ref user_agent) = configuration.user_agent {
112        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113    }
114    if let Some(ref token) = configuration.bearer_access_token {
115        req_builder = req_builder.bearer_auth(token.to_owned());
116    };
117
118    let req = req_builder.build()?;
119    let resp = configuration.client.execute(req).await?;
120
121    let status = resp.status();
122    let content_type = resp
123        .headers()
124        .get("content-type")
125        .and_then(|v| v.to_str().ok())
126        .unwrap_or("application/octet-stream");
127    let content_type = super::ContentType::from(content_type);
128
129    if !status.is_client_error() && !status.is_server_error() {
130        let content = resp.text().await?;
131        match content_type {
132            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
133            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
134            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
135        }
136    } else {
137        let content = resp.text().await?;
138        let entity: Option<WechatDecryptError> = serde_json::from_str(&content).ok();
139        Err(Error::ResponseError(ResponseContent { status, content, entity }))
140    }
141}
142
143/// 生成小程序的scheme码
144pub async fn wechat_generate_scheme(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<models::StringApiResponse, Error<WechatGenerateSchemeError>> {
145    // add a prefix to parameters to efficiently prevent name collisions
146    let p_app_key = app_key;
147    let p_body = body;
148
149    let uri_str = format!("{}/Wechat/{appKey}/GenerateScheme", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
150    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
151
152    if let Some(ref user_agent) = configuration.user_agent {
153        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154    }
155    if let Some(ref token) = configuration.bearer_access_token {
156        req_builder = req_builder.bearer_auth(token.to_owned());
157    };
158    req_builder = req_builder.json(&p_body);
159
160    let req = req_builder.build()?;
161    let resp = configuration.client.execute(req).await?;
162
163    let status = resp.status();
164    let content_type = resp
165        .headers()
166        .get("content-type")
167        .and_then(|v| v.to_str().ok())
168        .unwrap_or("application/octet-stream");
169    let content_type = super::ContentType::from(content_type);
170
171    if !status.is_client_error() && !status.is_server_error() {
172        let content = resp.text().await?;
173        match content_type {
174            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
175            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
176            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
177        }
178    } else {
179        let content = resp.text().await?;
180        let entity: Option<WechatGenerateSchemeError> = serde_json::from_str(&content).ok();
181        Err(Error::ResponseError(ResponseContent { status, content, entity }))
182    }
183}
184
185/// 校验小程序登录凭证
186pub async fn wechat_js_code2_session(configuration: &configuration::Configuration, app_key: &str, js_code: Option<&str>) -> Result<models::StringApiResponse, Error<WechatJsCode2SessionError>> {
187    // add a prefix to parameters to efficiently prevent name collisions
188    let p_app_key = app_key;
189    let p_js_code = js_code;
190
191    let uri_str = format!("{}/Wechat/{appKey}/JSCode2Session", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
192    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
193
194    if let Some(ref param_value) = p_js_code {
195        req_builder = req_builder.query(&[("js_code", &param_value.to_string())]);
196    }
197    if let Some(ref user_agent) = configuration.user_agent {
198        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
199    }
200    if let Some(ref token) = configuration.bearer_access_token {
201        req_builder = req_builder.bearer_auth(token.to_owned());
202    };
203
204    let req = req_builder.build()?;
205    let resp = configuration.client.execute(req).await?;
206
207    let status = resp.status();
208    let content_type = resp
209        .headers()
210        .get("content-type")
211        .and_then(|v| v.to_str().ok())
212        .unwrap_or("application/octet-stream");
213    let content_type = super::ContentType::from(content_type);
214
215    if !status.is_client_error() && !status.is_server_error() {
216        let content = resp.text().await?;
217        match content_type {
218            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
219            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
220            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
221        }
222    } else {
223        let content = resp.text().await?;
224        let entity: Option<WechatJsCode2SessionError> = serde_json::from_str(&content).ok();
225        Err(Error::ResponseError(ResponseContent { status, content, entity }))
226    }
227}
228
229/// 获取公众号H5的JS SDK配置
230pub async fn wechat_js_config(configuration: &configuration::Configuration, app_key: &str, url: Option<&str>) -> Result<models::WechatJsConfigResultApiResponse, Error<WechatJsConfigError>> {
231    // add a prefix to parameters to efficiently prevent name collisions
232    let p_app_key = app_key;
233    let p_url = url;
234
235    let uri_str = format!("{}/Wechat/{appKey}/JSConfig", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
236    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
237
238    if let Some(ref param_value) = p_url {
239        req_builder = req_builder.query(&[("url", &param_value.to_string())]);
240    }
241    if let Some(ref user_agent) = configuration.user_agent {
242        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
243    }
244    if let Some(ref token) = configuration.bearer_access_token {
245        req_builder = req_builder.bearer_auth(token.to_owned());
246    };
247
248    let req = req_builder.build()?;
249    let resp = configuration.client.execute(req).await?;
250
251    let status = resp.status();
252    let content_type = resp
253        .headers()
254        .get("content-type")
255        .and_then(|v| v.to_str().ok())
256        .unwrap_or("application/octet-stream");
257    let content_type = super::ContentType::from(content_type);
258
259    if !status.is_client_error() && !status.is_server_error() {
260        let content = resp.text().await?;
261        match content_type {
262            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
263            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WechatJsConfigResultApiResponse`"))),
264            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WechatJsConfigResultApiResponse`")))),
265        }
266    } else {
267        let content = resp.text().await?;
268        let entity: Option<WechatJsConfigError> = serde_json::from_str(&content).ok();
269        Err(Error::ResponseError(ResponseContent { status, content, entity }))
270    }
271}
272
273/// 发送公众号H5一次性订阅消息
274pub async fn wechat_subscribe_msg(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<models::StringApiResponse, Error<WechatSubscribeMsgError>> {
275    // add a prefix to parameters to efficiently prevent name collisions
276    let p_app_key = app_key;
277    let p_body = body;
278
279    let uri_str = format!("{}/Wechat/{appKey}/SubscribeMSG", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
280    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
281
282    if let Some(ref user_agent) = configuration.user_agent {
283        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
284    }
285    if let Some(ref token) = configuration.bearer_access_token {
286        req_builder = req_builder.bearer_auth(token.to_owned());
287    };
288    req_builder = req_builder.json(&p_body);
289
290    let req = req_builder.build()?;
291    let resp = configuration.client.execute(req).await?;
292
293    let status = resp.status();
294    let content_type = resp
295        .headers()
296        .get("content-type")
297        .and_then(|v| v.to_str().ok())
298        .unwrap_or("application/octet-stream");
299    let content_type = super::ContentType::from(content_type);
300
301    if !status.is_client_error() && !status.is_server_error() {
302        let content = resp.text().await?;
303        match content_type {
304            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
305            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
306            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
307        }
308    } else {
309        let content = resp.text().await?;
310        let entity: Option<WechatSubscribeMsgError> = serde_json::from_str(&content).ok();
311        Err(Error::ResponseError(ResponseContent { status, content, entity }))
312    }
313}
314
315/// 发送小程序订阅消息
316pub async fn wechat_subscribe_send(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<models::StringApiResponse, Error<WechatSubscribeSendError>> {
317    // add a prefix to parameters to efficiently prevent name collisions
318    let p_app_key = app_key;
319    let p_body = body;
320
321    let uri_str = format!("{}/Wechat/{appKey}/SubscribeSend", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
322    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
323
324    if let Some(ref user_agent) = configuration.user_agent {
325        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
326    }
327    if let Some(ref token) = configuration.bearer_access_token {
328        req_builder = req_builder.bearer_auth(token.to_owned());
329    };
330    req_builder = req_builder.json(&p_body);
331
332    let req = req_builder.build()?;
333    let resp = configuration.client.execute(req).await?;
334
335    let status = resp.status();
336    let content_type = resp
337        .headers()
338        .get("content-type")
339        .and_then(|v| v.to_str().ok())
340        .unwrap_or("application/octet-stream");
341    let content_type = super::ContentType::from(content_type);
342
343    if !status.is_client_error() && !status.is_server_error() {
344        let content = resp.text().await?;
345        match content_type {
346            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
347            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
348            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
349        }
350    } else {
351        let content = resp.text().await?;
352        let entity: Option<WechatSubscribeSendError> = serde_json::from_str(&content).ok();
353        Err(Error::ResponseError(ResponseContent { status, content, entity }))
354    }
355}
356
357/// 生成小程序的网页跳转地址
358pub async fn wechat_url_link_generate(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<models::StringApiResponse, Error<WechatUrlLinkGenerateError>> {
359    // add a prefix to parameters to efficiently prevent name collisions
360    let p_app_key = app_key;
361    let p_body = body;
362
363    let uri_str = format!("{}/Wechat/{appKey}/UrlLinkGenerate", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
364    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
365
366    if let Some(ref user_agent) = configuration.user_agent {
367        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
368    }
369    if let Some(ref token) = configuration.bearer_access_token {
370        req_builder = req_builder.bearer_auth(token.to_owned());
371    };
372    req_builder = req_builder.json(&p_body);
373
374    let req = req_builder.build()?;
375    let resp = configuration.client.execute(req).await?;
376
377    let status = resp.status();
378    let content_type = resp
379        .headers()
380        .get("content-type")
381        .and_then(|v| v.to_str().ok())
382        .unwrap_or("application/octet-stream");
383    let content_type = super::ContentType::from(content_type);
384
385    if !status.is_client_error() && !status.is_server_error() {
386        let content = resp.text().await?;
387        match content_type {
388            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
389            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
390            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
391        }
392    } else {
393        let content = resp.text().await?;
394        let entity: Option<WechatUrlLinkGenerateError> = serde_json::from_str(&content).ok();
395        Err(Error::ResponseError(ResponseContent { status, content, entity }))
396    }
397}
398
399/// 获取公众号H5用户的UnionID
400pub async fn wechat_user_info(configuration: &configuration::Configuration, app_key: &str, openid: Option<&str>) -> Result<models::StringApiResponse, Error<WechatUserInfoError>> {
401    // add a prefix to parameters to efficiently prevent name collisions
402    let p_app_key = app_key;
403    let p_openid = openid;
404
405    let uri_str = format!("{}/Wechat/{appKey}/UserInfo", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
406    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
407
408    if let Some(ref param_value) = p_openid {
409        req_builder = req_builder.query(&[("openid", &param_value.to_string())]);
410    }
411    if let Some(ref user_agent) = configuration.user_agent {
412        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
413    }
414    if let Some(ref token) = configuration.bearer_access_token {
415        req_builder = req_builder.bearer_auth(token.to_owned());
416    };
417
418    let req = req_builder.build()?;
419    let resp = configuration.client.execute(req).await?;
420
421    let status = resp.status();
422    let content_type = resp
423        .headers()
424        .get("content-type")
425        .and_then(|v| v.to_str().ok())
426        .unwrap_or("application/octet-stream");
427    let content_type = super::ContentType::from(content_type);
428
429    if !status.is_client_error() && !status.is_server_error() {
430        let content = resp.text().await?;
431        match content_type {
432            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
433            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
434            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::StringApiResponse`")))),
435        }
436    } else {
437        let content = resp.text().await?;
438        let entity: Option<WechatUserInfoError> = serde_json::from_str(&content).ok();
439        Err(Error::ResponseError(ResponseContent { status, content, entity }))
440    }
441}
442
443/// 获取小程序码
444pub async fn wechat_wxa_code_get(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<reqwest::Response, Error<WechatWxaCodeGetError>> {
445    // add a prefix to parameters to efficiently prevent name collisions
446    let p_app_key = app_key;
447    let p_body = body;
448
449    let uri_str = format!("{}/Wechat/{appKey}/WXACodeGet", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
450    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
451
452    if let Some(ref user_agent) = configuration.user_agent {
453        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
454    }
455    if let Some(ref token) = configuration.bearer_access_token {
456        req_builder = req_builder.bearer_auth(token.to_owned());
457    };
458    req_builder = req_builder.json(&p_body);
459
460    let req = req_builder.build()?;
461    let resp = configuration.client.execute(req).await?;
462
463    let status = resp.status();
464
465    if !status.is_client_error() && !status.is_server_error() {
466        Ok(resp)
467    } else {
468        let content = resp.text().await?;
469        let entity: Option<WechatWxaCodeGetError> = serde_json::from_str(&content).ok();
470        Err(Error::ResponseError(ResponseContent { status, content, entity }))
471    }
472}
473
474/// 获取无限制的小程序码
475pub async fn wechat_wxa_code_get_unlimited(configuration: &configuration::Configuration, app_key: &str, body: Option<serde_json::Value>) -> Result<reqwest::Response, Error<WechatWxaCodeGetUnlimitedError>> {
476    // add a prefix to parameters to efficiently prevent name collisions
477    let p_app_key = app_key;
478    let p_body = body;
479
480    let uri_str = format!("{}/Wechat/{appKey}/WXACodeGetUnlimited", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
481    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
482
483    if let Some(ref user_agent) = configuration.user_agent {
484        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
485    }
486    if let Some(ref token) = configuration.bearer_access_token {
487        req_builder = req_builder.bearer_auth(token.to_owned());
488    };
489    req_builder = req_builder.json(&p_body);
490
491    let req = req_builder.build()?;
492    let resp = configuration.client.execute(req).await?;
493
494    let status = resp.status();
495
496    if !status.is_client_error() && !status.is_server_error() {
497        Ok(resp)
498    } else {
499        let content = resp.text().await?;
500        let entity: Option<WechatWxaCodeGetUnlimitedError> = serde_json::from_str(&content).ok();
501        Err(Error::ResponseError(ResponseContent { status, content, entity }))
502    }
503}
504