Skip to content

Commit

Permalink
新增2023/01/10企微更新内容
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmhub committed Jan 10, 2023
1 parent 971b350 commit 4e68cf5
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 0 deletions.
75 changes: 75 additions & 0 deletions apis/上下游-批量导入上下游联系人.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package apis

import (
"encoding/json"
)

// 自动生成的文件, 生成方式: make api doc=微信文档地址url
// 可自行修改生成的文件,以满足开发需求

// ReqImportChainContactCorpgroup 批量导入上下游联系人请求
// 文档:https://developer.work.weixin.qq.com/document/path/95821
type ReqImportChainContactCorpgroup struct {
// ChainID 上下游id。文件中的联系人将会被导入此上下游中,必填
ChainID string `json:"chain_id"`
ContactList []struct {
ContactInfoList []struct {
// IdentityType 联系人身份类型。1:成员,2:负责人。,必填
IdentityType int `json:"identity_type"`
// Mobile 手机号。支持国内、国际手机号(国内手机号直接输入手机号即可,格式示例:“138****0001”;国际手机号必须包含加号以及国家地区码,格式示例:“+85259****45”,必填
Mobile string `json:"mobile"`
// Name 上下游联系人姓名。长度为1~32个utf8字符,必填
Name string `json:"name"`
// UserCustomID 上下游用户自定义 id。类型为字符串,暂时只支持传入64比特无符号整型,取值范围1到2^64-2,必须是全数字,不得传入前置0,且不能为11位或13位数字。
UserCustomID string `json:"user_custom_id,omitempty"`
} `json:"contact_info_list"` // 上下游联系人信息列表,必填
// CorpName 上下游企业名称。长度为1-32个utf8字符。只能由中文、字母、数字和“ -_()()”六种字符组成,必填
CorpName string `json:"corp_name"`
// CustomID 上下游企业自定义 id。长度为0~64 个字节,只能由数字和字母组成
CustomID string `json:"custom_id,omitempty"`
// GroupPath 导入后企业所在分组。分组为空的企业会放在根分组下。仅针对新导入企业生效,不会修改已导入企业的分组。
GroupPath string `json:"group_path,omitempty"`
} `json:"contact_list"` // 上下游联系人列表。这些联系人将会被导入此上下游中,必填
}

var _ bodyer = ReqImportChainContactCorpgroup{}

func (x ReqImportChainContactCorpgroup) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// RespImportChainContactCorpgroup 批量导入上下游联系人响应
// 文档:https://developer.work.weixin.qq.com/document/path/95821
type RespImportChainContactCorpgroup struct {
CommonResp
// Jobid 异步任务id,最大长度为64字节
Jobid string `json:"jobid"`
}

var _ bodyer = RespImportChainContactCorpgroup{}

func (x RespImportChainContactCorpgroup) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// ExecImportChainContactCorpgroup 批量导入上下游联系人
// 文档:https://developer.work.weixin.qq.com/document/path/95821
func (c *ApiClient) ExecImportChainContactCorpgroup(req ReqImportChainContactCorpgroup) (RespImportChainContactCorpgroup, error) {
var resp RespImportChainContactCorpgroup
err := c.executeWXApiPost("/cgi-bin/corpgroup/import_chain_contact", req, &resp, true)
if err != nil {
return RespImportChainContactCorpgroup{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespImportChainContactCorpgroup{}, bizErr
}
return resp, nil
}
59 changes: 59 additions & 0 deletions apis/上下游-移除企业.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package apis

import (
"encoding/json"
)

// 自动生成的文件, 生成方式: make api doc=微信文档地址url
// 可自行修改生成的文件,以满足开发需求

// ReqRemoveCorpCorp 移除企业请求
// 文档:https://developer.work.weixin.qq.com/document/path/95822#移除企业
type ReqRemoveCorpCorp struct {
// ChainID 上下游id,必填
ChainID string `json:"chain_id"`
// Corpid 需要移除的下游企业corpid
Corpid string `json:"corpid,omitempty"`
// PendingCorpid 需要移除的未加入下游企业corpid,corpid和pending_corpid至少填一个,都填corpid生效
PendingCorpid string `json:"pending_corpid,omitempty"`
}

var _ bodyer = ReqRemoveCorpCorp{}

func (x ReqRemoveCorpCorp) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// RespRemoveCorpCorp 移除企业响应
// 文档:https://developer.work.weixin.qq.com/document/path/95822#移除企业
type RespRemoveCorpCorp struct {
CommonResp
}

var _ bodyer = RespRemoveCorpCorp{}

func (x RespRemoveCorpCorp) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// ExecRemoveCorpCorp 移除企业
// 文档:https://developer.work.weixin.qq.com/document/path/95822#移除企业
func (c *ApiClient) ExecRemoveCorpCorp(req ReqRemoveCorpCorp) (RespRemoveCorpCorp, error) {
var resp RespRemoveCorpCorp
err := c.executeWXApiPost("/cgi-bin/corpgroup/corp/remove_corp", req, &resp, true)
if err != nil {
return RespRemoveCorpCorp{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespRemoveCorpCorp{}, bizErr
}
return resp, nil
}
3 changes: 3 additions & 0 deletions callbacks/callback_constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ const EventTypeCloseInactiveAgent = "close_inactive_agent"
// 长期未使用应用重新启用事件
const EventTypeReopenInactiveAgent = "reopen_inactive_agent"

// 扫描推广二维码事件
const EventTypeEnterRegisterPackage = "enter_register_package"

// 推送suite_ticket
const InfoTypeSuiteTicket EventType = "suite_ticket"

Expand Down
66 changes: 66 additions & 0 deletions callbacks/third扫描推广二维码事件.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package callbacks

import "encoding/xml"

// 自动生成的回调结构,按需修改, 生成方式: make callback doc=微信文档地址url
// 文档: https://developer.work.weixin.qq.com/document/path/98071#扫描推广二维码事件

func init() {
//添加可解析的回调事件
supportCallback(ThirdEnterRegisterPackage{})
}

// XML was generated 2023-01-10 11:28:56 by insomnia on insomnia.lan.
type ThirdEnterRegisterPackage struct {
XMLName xml.Name `xml:"xml"`
Text string `xml:",chardata"`
ServiceCorpId struct {
Text string `xml:",chardata"`
} `xml:"ServiceCorpId"`
InfoType struct {
Text string `xml:",chardata"`
} `xml:"InfoType"`
TimeStamp struct {
Text string `xml:",chardata"`
} `xml:"TimeStamp"`
AuthCorpId struct {
Text string `xml:",chardata"`
} `xml:"AuthCorpId"`
AuthUserInfo struct {
Text string `xml:",chardata"`
UserId struct {
Text string `xml:",chardata"`
} `xml:"UserId"`
} `xml:"AuthUserInfo"`
RegisterCode struct {
Text string `xml:",chardata"`
} `xml:"RegisterCode"`
State struct {
Text string `xml:",chardata"`
} `xml:"State"`
TemplateId struct {
Text string `xml:",chardata"`
} `xml:"TemplateId"`
}

func (ThirdEnterRegisterPackage) GetMessageType() string {
return "third"
}

func (ThirdEnterRegisterPackage) GetEventType() string {
return "enter_register_package"
}

func (ThirdEnterRegisterPackage) GetChangeType() string {
return ""
}

func (m ThirdEnterRegisterPackage) GetTypeKey() string {
return m.GetMessageType() + ":" + m.GetEventType() + ":" + m.GetChangeType()
}

func (ThirdEnterRegisterPackage) ParseFromXml(data []byte) (CallBackExtraInfoInterface, error) {
var temp ThirdEnterRegisterPackage
err := xml.Unmarshal(data, &temp)
return temp, err
}

0 comments on commit 4e68cf5

Please sign in to comment.