Skip to content

Commit

Permalink
Merge pull request #5 from wslongchen/develop
Browse files Browse the repository at this point in the history
feat(develop): Add some features
  • Loading branch information
wslongchen authored Aug 26, 2022
2 parents 5ea0118 + 7606f08 commit a926acd
Show file tree
Hide file tree
Showing 16 changed files with 762 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "labrador"
version = "0.1.6"
version = "0.1.7"
authors = ["mrpan <1049058427@qq.com>"]
edition = "2018"
description = "Labrador - Mini thidpart client for rust."
description = "Labrador - Mini thirdpart client for rust."
readme = "README.md"
keywords = ["alipay", "wechat", "jd", "taobao", "pdd"]
categories = ["api-bindings"]
Expand Down
5 changes: 0 additions & 5 deletions src/wechat/cp/api/external_contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,12 @@ impl<'a, T: SessionStore> WechatCpExternalContact<'a, T> {
///
/// <pre>
/// 注意::
/// <p>
/// 群主离职了的客户群,才可继承
/// 继承给的新群主,必须是配置了客户联系功能的成员
/// 继承给的新群主,必须有设置实名
/// 继承给的新群主,必须有激活企业微信
/// 同一个人的群,限制每天最多分配300个给新群主
/// <p>
/// 权限说明:
/// <p>
/// 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
/// 第三方应用需拥有“企业客户权限->客户联系->分配离职成员的客户群”权限
/// 对于第三方/自建应用,群主必须在应用的可见范围。
Expand Down Expand Up @@ -468,9 +465,7 @@ impl<'a, T: SessionStore> WechatCpExternalContact<'a, T> {
/// 企业可通过此接口添加企业群发消息的任务并通知客服人员发送给相关客户或客户群。(注:企业微信终端需升级到2.7.5版本及以上)
/// 注意:调用该接口并不会直接发送消息给客户/客户群,需要相关的客服人员操作以后才会实际发送(客服人员的企业微信需要升级到2.7.5及以上版本)
/// 同一个企业每个自然月内仅可针对一个客户/客户群发送4条消息,超过限制的用户将会被忽略。
/// <p>
/// 请求方式: POST(HTTP)
/// <p>
/// 请求地址:<a href="https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=ACCESS_TOKEN">地址</a>
/// <p>
/// 文档地址:<a href="https://work.weixin.qq.com/api/doc/90000/90135/92135">地址</a>
Expand Down
2 changes: 0 additions & 2 deletions src/wechat/miniapp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ impl<T: SessionStore> WeChatMaClient<T> {
let expires_in = res.expires_in;
// 预留200秒的时间
let expires_at = current_timestamp() + expires_in - 200;
let token_key = format!("{}_access_token", self.appid);
let expires_key = format!("{}_expires_at", self.appid);
session.set(&token_key, token.to_owned(), Some(expires_in as usize));
session.set(&expires_key, expires_at, Some(expires_in as usize));
Ok(token)
Expand Down
6 changes: 3 additions & 3 deletions src/wechat/mp/api/customservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ impl<'a, T: SessionStore> WeChatMpCustomService<'a, T> {

//----------------------------------------------------------------------------------------------------------------------------

#[derive(Debug, Clone, PartialEq, Eq,Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KFAccount {
pub id: String,
pub nick: String,
pub account: String,
pub avatar: String,
}

#[derive(Debug, Clone, PartialEq, Eq,Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OnlineKFAccount {
pub id: String,
pub account: String,
Expand Down Expand Up @@ -280,7 +280,7 @@ impl SendImageRequest {
}


#[derive(Debug, Clone, PartialEq, Eq,Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SendTextRequest {
openid: String,
account: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/wechat/mp/api/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'a, T: SessionStore> WechatMpMedia<'a, T> {
/// 3、素材的格式大小等要求与公众平台官网一致。具体是,图片大小不超过2M,支持bmp/png/jpeg/jpg/gif格式,语音大小不超过5M,长度不超过60秒,支持mp3/wma/wav/amr格式
/// 4、调用该接口需https协议
/// </pre>
pub async fn upload_material(&self, media_type: &str, req: WechatMpMaterialRequest) -> LabradorResult<WechatMpMediaResponse> {
pub async fn upload_material(&self, req: WechatMpMaterialRequest) -> LabradorResult<WechatMpMediaResponse> {
let v = self.client.execute::<WechatMpMaterialRequest, String>(req).await?.json::<Value>()?;
WechatCommonResponse::parse::<WechatMpMediaResponse>(v)
}
Expand Down
20 changes: 10 additions & 10 deletions src/wechat/mp/api/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ impl<'a, T: SessionStore> WeChatMpMenu<'a, T> {

//----------------------------------------------------------------------------------------------------------------------------

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MenuButtonsRequest {
/// 一级菜单数组,个数应为1~3个
pub button: Vec<MenuButton>,
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MenuButton {
#[serde(rename = "type")]
pub button_type: String,
Expand All @@ -146,22 +146,22 @@ pub struct MenuButton {
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuInfoResponse {
/// 菜单是否开启,0代表未开启,1代表开启
pub is_menu_open: Option<u8>,
/// 菜单标题,不超过16个字节,子菜单不超过60个字节
pub selfmenu_info: Option<SelfMenuInfo>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuInfo {
/// 菜单是否开启,0代表未开启,1代表开启
pub button: Option<Vec<SelfMenuButton>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuButton {
#[serde(rename = "type")]
pub button_type: Option<String>,
Expand All @@ -186,17 +186,17 @@ pub struct SelfMenuButton {

}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuSubButton {
pub list: Option<Vec<SelfMenuButton>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuNewsButton {
pub list: Option<Vec<SelfMenuNewsInfo>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfMenuNewsInfo {
/// 图文消息的标题
pub title: Option<String>,
Expand All @@ -215,14 +215,14 @@ pub struct SelfMenuNewsInfo {
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MenuButtonResponse {
pub menu: Option<MenuButtonsInner>,
pub conditionalmenu: Option<MenuButtonsInner>,
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MenuButtonsInner {
/// 一级菜单数组,个数应为1~3个
pub button: Option<Vec<MenuButton>>,
Expand Down
4 changes: 4 additions & 0 deletions src/wechat/mp/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ mod oauth2;
mod media;
mod template_msg;
mod subscribe_msg;
mod wifi;
mod ocr;

pub use self::oauth2::*;
pub use self::qrcode::*;
Expand All @@ -15,5 +17,7 @@ pub use self::template_msg::*;
pub use self::subscribe_msg::*;
pub use self::media::*;
pub use self::menu::*;
pub use self::wifi::*;
pub use self::ocr::*;


2 changes: 1 addition & 1 deletion src/wechat/mp/api/oauth2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct WechatMpOauth2AccessTokenResponse{
}


#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WechatMpOauth2UserInfo {
pub openid: String,
pub nickname: String,
Expand Down
Loading

0 comments on commit a926acd

Please sign in to comment.