application

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddExternalContactCallbackMessage

type AddExternalContactCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
	State          string `json:"state"`
	WelcomeCode    string `json:"welcome_code"`
}

AddExternalContactCallbackMessage 添加企业客户事件

type AddHalfExternalContactCallbackMessage

type AddHalfExternalContactCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
	State          string `json:"state"`
	WelcomeCode    string `json:"welcome_code"`
}

AddHalfExternalContactCallbackMessage 外部联系人免验证添加成员事件

type Agentlist

type Agentlist struct {
	Agentid       int    `json:"agentid"`
	Name          string `json:"name"`
	SquareLogoURL string `json:"square_logo_url"`
}

type AllowPartys

type AllowPartys struct {
	Partyid []int `json:"partyid"`
}

type AllowTags

type AllowTags struct {
	Tagid []int `json:"tagid"`
}

type AllowUserinfos

type AllowUserinfos struct {
	User []User `json:"user"`
}

type AuditApprovedCallbackMessage

type AuditApprovedCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
	WelcomeCode    string `json:"welcome_code"`
}

客户同意进行聊天内容存档事件回调

type Button

type Button struct {
	Name      string      `json:"name"`
	SubButton []SubButton `json:"sub_button,omitempty"`
	Type      string      `json:"type,omitempty"`
	Key       string      `json:"key,omitempty"`
}

type CallbackMessage

type CallbackMessage struct {
	ToUserName   string `json:"to_user_name"`   // 企业微信CorpID
	FromUserName string `json:"from_user_name"` // 此事件该值固定为sys,表示该消息由系统生成
	CreateTime   int    `json:"create_time"`    // 消息创建时间 (整型)
	MsgType      string `json:"msgtype"`        // 消息的类型,此时固定为event
	Event        string `json:"event"`          // 事件的类型,此时固定为change_contact
	ChangeType   string `json:"change_type"`    // 此时固定为delete_user
}

CallbackMessage 基础回调消息

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client application实例

func NewClient

func NewClient(cfg *config.Config) (client *Client, err error)

NewClient 初始化实例

func (*Client) CreateMenu

func (r *Client) CreateMenu(options CreateMenuOptions) (info CreateMenuSchema, err error)

CreateMenu 创建菜单

func (*Client) DeleteMenu

func (r *Client) DeleteMenu() (info DeleteMenuSchema, err error)

DeleteMenu 删除菜单

func (*Client) GetApplicationInfo

func (r *Client) GetApplicationInfo() (info GetApplicationInfoSchema, err error)

GetApplicationInfo 获取指定的应用详情

func (*Client) GetApplicationList

func (r *Client) GetApplicationList() (info GetApplicationListSchema, err error)

GetApplicationList 获取access_token对应的应用列表

func (*Client) GetCallbackMessage

func (r *Client) GetCallbackMessage(signatureOptions SignatureOptions, encryptedMsg []byte) (rawData []byte, msg CallbackMessage, err error)

GetCallbackMessage 获取回调事件中的消息内容

 //Gin框架的使用示例
	r.POST("/v1/event/callback", func(c *gin.Context) {
		var (
			message kf.CallbackMessage
			body []byte
		)
		// 读取原始消息内容
		body, err = c.GetRawData()
		if err != nil {
			c.String(http.StatusInternalServerError, err.Error())
			return
		}
		// 解析原始数据
		message, err = kfClient.GetCallbackMessage(body)
		if err != nil {
			c.String(http.StatusInternalServerError, "消息获取失败")
			return
		}
		fmt.Println(message)
		c.String(200, "ok")
	})

func (*Client) GetMenu

func (r *Client) GetMenu() (info GetMenuSchema, err error)

GetMenu 获取菜单

func (*Client) SetApplicationInfo

func (r *Client) SetApplicationInfo(options SetApplicationInfoOptions) (info SetApplicationInfoSchema, err error)

SetApplicationInfo 设置应用详情

func (*Client) VerifyURL

func (r *Client) VerifyURL(options SignatureOptions) (string, error)

VerifyURL 验证请求参数是否合法并返回解密后的消息内容

 //Gin框架的使用示例
	r.GET("/v1/event/callback", func(c *gin.Context) {
		options := kf.SignatureOptions{}
		//获取回调的的校验参数
		if = c.ShouldBindQuery(&options); err != nil {
			c.String(http.StatusUnauthorized, "参数解析失败")
		}
		// 调用VerifyURL方法校验当前请求,如果合法则把解密后的内容作为响应返回给微信服务器
		echo, err := kfClient.VerifyURL(options)
		if err == nil {
			c.String(http.StatusOK, echo)
		} else {
			c.String(http.StatusUnauthorized, "非法请求来源")
		}
	})

type CreateCallbackMessage

type CreateCallbackMessage struct {
	CallbackMessage
	ChatId string `json:"ChatId"`
}

CreateCallbackMessage 客户群创建事件

type CreateMenuOptions

type CreateMenuOptions struct {
	Button []Button `json:"button"`
}

CreateMenuOptions 创建菜单请求参数

type CreateMenuSchema

type CreateMenuSchema struct {
	util.CommonError
}

CreateMenuSchema 创建菜单响应内容

type DelExternalContactCallbackMessage

type DelExternalContactCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
	Source         string `json:"source"`
}

DelExternalContactCallbackMessage 删除企业客户事件

type DelFollowUserCallbackMessage

type DelFollowUserCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
}

DelFollowUserCallbackMessage 删除跟进成员事件

type DeleteMenuOptions

type DeleteMenuOptions struct {
}

DeleteMenuOptions 删除菜单请求参数

type DeleteMenuSchema

type DeleteMenuSchema struct {
	util.CommonError
}

DeleteMenuSchema 删除菜单响应内容

type DismissCallbackMessage

type DismissCallbackMessage struct {
	CallbackMessage
	ChatId string `json:"chat_id"`
}

DismissCallbackMessage 客户群解散事件

type EditExternalContactCallbackMessage

type EditExternalContactCallbackMessage struct {
	CallbackMessage
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
}

EditExternalContactCallbackMessage 编辑企业客户事件

type Error

type Error string

Error 错误

const (
	// SDKInitFailed 错误码:50001
	SDKInitFailed Error = "SDK初始化失败"
	// SDKCacheUnavailable 错误码:50002
	SDKCacheUnavailable Error = "缓存无效"
	// SDKUnknownError 错误码:50003
	SDKUnknownError Error = "未知错误"
	// SDKInvalidCredential 错误码:40001
	SDKInvalidCredential Error = "不合法的secret参数"
	// SDKInvalidCorpID 错误码:40013
	SDKInvalidCorpID Error = "无效的 CorpID"
	// SDKAccessTokenInvalid 错误码:40014
	SDKAccessTokenInvalid Error = "AccessToken 无效"
	// SDKValidateSignatureFailed 错误码:40015
	SDKValidateSignatureFailed Error = "校验签名错误"
	// SDKDecryptMSGFailed 错误码:40016
	SDKDecryptMSGFailed Error = "消息解密失败"
	// SDKAccessTokenMissing 错误码:41001
	SDKAccessTokenMissing Error = "缺少AccessToken参数"
	// SDKAccessTokenExpired 错误码:42001
	SDKAccessTokenExpired Error = "AccessToken 已过期"
	// SDKApiFreqOutOfLimit 错误码:45009
	SDKApiFreqOutOfLimit Error = "接口请求次数超频"
	// SDKApiForbidden 错误码:48002
	SDKApiForbidden Error = "API 禁止调用"
	// SDKInvalidOpenKFID 错误码:95000
	SDKInvalidOpenKFID Error = "无效的 open_kfid"
	// SDKOpenKFIDNotExist 错误码:95004
	SDKOpenKFIDNotExist Error = "open_kfid 不存在"
	// SDKWeWorkAlready 错误码:95011
	SDKWeWorkAlready Error = "已在企业微信使用微信客服"
	// SDKNotUseInWeCom 错误码:95012
	SDKNotUseInWeCom Error = "未在企业微信使用微信客服"
	// SDKApiNotOpen 错误码:95017
	SDKApiNotOpen Error = "API 功能没有被开启"
)

func NewSDKErr

func NewSDKErr(code int64, msgList ...string) Error

NewSDKErr 初始化SDK实例错误信息

func (Error) Error

func (r Error) Error() string

Error 输出错误信息

type GetApplicationInfoOptions

type GetApplicationInfoOptions struct {
}

GetApplicationInfoOptions 获取指定的应用详情请求参数

type GetApplicationInfoSchema

type GetApplicationInfoSchema struct {
	util.CommonError
	Agentid            int            `json:"agentid"`
	Name               string         `json:"name"`
	SquareLogoURL      string         `json:"square_logo_url"`
	Description        string         `json:"description"`
	AllowUserinfos     AllowUserinfos `json:"allow_userinfos"`
	AllowPartys        AllowPartys    `json:"allow_partys"`
	AllowTags          AllowTags      `json:"allow_tags"`
	Close              int            `json:"close"`
	RedirectDomain     string         `json:"redirect_domain"`
	ReportLocationFlag int            `json:"report_location_flag"`
	Isreportenter      int            `json:"isreportenter"`
	HomeURL            string         `json:"home_url"`
}

GetApplicationInfoSchema 获取指定的应用详情响应内容

type GetApplicationListOptions

type GetApplicationListOptions struct {
}

GetApplicationListOptions 获取access_token对应的应用列表请求参数

type GetApplicationListSchema

type GetApplicationListSchema struct {
	util.CommonError
	Agentlist []Agentlist `json:"agentlist"`
}

GetApplicationListSchema 获取access_token对应的应用列表响应内容

type GetMenuOptions

type GetMenuOptions struct {
}

GetMenuOptions 获取菜单请求参数

type GetMenuSchema

type GetMenuSchema struct {
	util.CommonError
	Button []Button `json:"button"`
}

GetMenuSchema 获取菜单响应内容

type SetApplicationInfoOptions

type SetApplicationInfoOptions struct {
	Agentid            int    `json:"agentid"`
	ReportLocationFlag int    `json:"report_location_flag"`
	LogoMediaid        string `json:"logo_mediaid"`
	Name               string `json:"name"`
	Description        string `json:"description"`
	RedirectDomain     string `json:"redirect_domain"`
	Isreportenter      int    `json:"isreportenter"`
	HomeURL            string `json:"home_url"`
}

SetApplicationInfoOptions 设置应用详情请求参数

type SetApplicationInfoSchema

type SetApplicationInfoSchema struct {
	util.CommonError
}

SetApplicationInfoSchema 设置应用详情响应内容

type SignatureOptions

type SignatureOptions struct {
	Signature string `form:"msg_signature"`
	TimeStamp string `form:"timestamp"`
	Nonce     string `form:"nonce"`
	EchoStr   string `form:"echostr"`
	Encrypt   string `form:"encrypt"`
}

SignatureOptions 微信服务器验证参数

type SubButton

type SubButton struct {
	Type      string        `json:"type"`
	Name      string        `json:"name"`
	URL       string        `json:"url,omitempty"`
	Key       string        `json:"key,omitempty"`
	SubButton []interface{} `json:"sub_button,omitempty"`
	Pagepath  string        `json:"pagepath,omitempty"`
	Appid     string        `json:"appid,omitempty"`
}

type TagCreateCallbackMessage

type TagCreateCallbackMessage struct {
	CallbackMessage
	Id      string `json:"id"`
	TagType string `json:"tag_type"`
}

TagCreateCallbackMessage 企业客户标签创建事件

type TagDeleteCallbackMessage

type TagDeleteCallbackMessage struct {
	CallbackMessage
	Id      string `json:"id"`
	TagType string `json:"tag_type"`
}

TagDeleteCallbackMessage 企业客户标签删除事件

type TagShuffleCallbackMessage

type TagShuffleCallbackMessage struct {
	CallbackMessage
	Id         string `json:"id"`
	StrategyID string `json:"strategy_id"`
}

TagShuffleCallbackMessage 企业客户标签重排事件

type TagUpdateCallbackMessage

type TagUpdateCallbackMessage struct {
	CallbackMessage
	Id      string `json:"id"`
	TagType string `json:"tag_type"`
}

TagUpdateCallbackMessage 企业客户标签变更事件

type TransferFailCallbackMessage

type TransferFailCallbackMessage struct {
	CallbackMessage
	FailReason     string `json:"fail_reason"`
	UserID         string `json:"user_id"`
	ExternalUserID string `json:"external_user_id"`
}

TransferFailCallbackMessage 客户接替失败事件

type UpdateCallbackMessage

type UpdateCallbackMessage struct {
	CallbackMessage
	ChatId       string `json:"chat_id"`
	UpdateDetail string `json:"update_detail"`
	JoinScene    int    `json:"join_scene"`
	QuitScene    int    `json:"quit_scene"`
	MemChangeCnt int    `json:"mem_change_cnt"`
}

UpdateCallbackMessage 客户群变更事件

type User

type User struct {
	Userid string `json:"userid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL