use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{common::AccessTokenData, wxcorp_api_get, wxcorp_api_post};
wxcorp_api_get!(
request_access_token,
"https://qyapi.weixin.qq.com/cgi-bin/gettoken",
(corpid: Option<&str>, corpsecret: Option<&str>),
AccessTokenData
);
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged, rename_all_fields(deserialize = "PascalCase"))]
pub enum UserIdInfoByAuthCode {
Inner {
user_id: String,
},
External {
open_id: String,
external_user_id: Option<String>,
},
}
wxcorp_api_get!(
request_user_id_by_auth_code,
"https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo",
(access_token: Option<&str>, code: Option<&str>),
UserIdInfoByAuthCode
);
#[derive(Debug, Serialize, Deserialize)]
pub struct UserInfo {
pub userid: String,
pub name: Option<String>,
pub avatar: Option<String>,
pub department: Vec<i32>,
pub order: Vec<i32>,
}
wxcorp_api_get!(
request_user_info_by_user_id,
"https://qyapi.weixin.qq.com/cgi-bin/user/get",
(access_token: Option<&str>, userid: Option<&str>),
UserInfo
);
wxcorp_api_post!(
request_send,
"https://qyapi.weixin.qq.com/cgi-bin/message/send",
(access_token: Option<&str>),
&Value,
Value
);
wxcorp_api_post!(
request_webhook_send,
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send",
(key: Option<&str>),
&Value,
Value
);