wework

package module
v0.0.0-...-09a1ec8 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTokenNotFound = 41001 // 没有token
	ErrorToken         = 40014 // token不合法
	ErrorSystemBusy    = -1    // 系统繁忙

)

企业微信错误码

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatInfo

type ChatInfo struct {
	ChatId   string   `json:"chatid"`
	Name     string   `json:"name"`
	Owner    string   `json:"owner"`
	UserList []string `json:"userlist"`
}

ChatInfo 群聊详情

type ChatMarkdownMsg

type ChatMarkdownMsg struct {
	Markdown struct {
		Content string `json:"content"`
	} `json:"markdown"`
	// contains filtered or unexported fields
}

ChatMarkdownMsg 群聊Markdown消息推送参数

type ChatResponse

type ChatResponse struct {
	Errcode   int      `json:"errcode"`
	Errmsg    string   `json:"errmsg"`
	ChatInfos ChatInfo `json:"chat_info"`
}

ChatResponse chat api response

type ChatTextMsg

type ChatTextMsg struct {
	Text struct {
		Content string `json:"content"`
	} `json:"text"`
	// contains filtered or unexported fields
}

ChatTextMsg 群聊文本消息推送参数

type Client

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

Client 企业微信client

func New

func New(host, corpID, corpSecret string, agentID int64) (*Client, error)

New 初始化一个企业微信client

func (*Client) AllDept

func (wx *Client) AllDept() ([]Department, error)

AllDept 获取企业所有部门

func (*Client) ChatMarkdownPush

func (wx *Client) ChatMarkdownPush(ChatId, content string) error

ChatMarkdownPush 群聊Markdown消息推送

func (*Client) ChatTextPush

func (wx *Client) ChatTextPush(ChatId, content string) error

ChatTextPush 群聊文本消息推送

func (*Client) CreateChat

func (wx *Client) CreateChat(name, chatId string, users []string) error

CreateChat 创建群聊

func (*Client) DeptByID

func (wx *Client) DeptByID(departmentID string) ([]Department, error)

DeptByID 通过部门id获取部门详情

func (*Client) Get

func (wx *Client) Get(api string, params ...string) ([]byte, error)

Get get请求企微api @Param api string

func (*Client) GetChat

func (wx *Client) GetChat(chatId string) (ChatInfo, error)

GetChat 获取群聊信息

func (*Client) Post

func (wx *Client) Post(api string, data []byte) ([]byte, error)

Post post请求企微api

func (*Client) SetRetry

func (wx *Client) SetRetry(reTry int) *Client

SetRetry 设置重试次数, 仅适用于网络故障或服务器错误码-1的情况 @Param int

func (*Client) UpdateChat

func (wx *Client) UpdateChat(name, chatId, owner string, addUsers, delUsers []string) error

UpdateChat 更新群聊

func (*Client) Use

func (wx *Client) Use(handlerFunc ...HandlerFunc) *Client

Use 增加返回错误码处理中间件 @Param HandlerFunc

func (*Client) UserByID

func (wx *Client) UserByID(userID string) (UserDetail, error)

UserByID 通过user_id获取用户详情

func (*Client) UserMarkdownPush

func (wx *Client) UserMarkdownPush(users, content string) error

UserMarkdownPush 私信Markdown消息推送

func (*Client) UserTextPush

func (wx *Client) UserTextPush(users, content string) error

UserTextPush 私信文本消息推送

func (*Client) UsersByDeptID

func (wx *Client) UsersByDeptID(departmentID string) ([]UserDetail, error)

UsersByDeptID 通过部门id获取用户详情

type Department

type Department struct {
	Id       int    `json:"id"`
	Name     string `json:"name"`
	NameEn   string `json:"name_en"`
	ParentID int    `json:"parentid"`
	Order    int    `json:"order"`
}

Department 部门详情

type DepartmentList

type DepartmentList struct {
	Errcode    int          `json:"errcode"`
	Errmsg     string       `json:"errmsg"`
	Department []Department `json:"department"`
}

DepartmentList 部门详情列表

type HandlerFunc

type HandlerFunc func(wx *Client, api string, res *errResponse, data *[]byte) bool

HandlerFunc api response 钩子函数

type HandlersChan

type HandlersChan []HandlerFunc

HandlersChan api response 钩子函数数组

type UserDetail

type UserDetail struct {
	Userid         string `json:"userid" `
	Name           string `json:"name"`
	Department     []int  `json:"department"`
	Order          []int  `json:"order"`
	Position       string `json:"position"`
	Mobile         string `json:"mobile"`
	Gender         string `json:"gender"`
	Email          string `json:"email"`
	IsLeaderInDept []int  `json:"is_leader_in_dept"`
	Avatar         string `json:"avatar"`
	ThumbAvatar    string `json:"thumb_avatar"`
	Telephone      string `json:"telephone"`
	Alias          string `json:"alias"`
	Address        string `json:"address"`
	OpenUserid     string `json:"open_userid"`
	MainDepartment int    `json:"main_department"`
	ExtAttr        struct {
		Attrs []struct {
			Type int    `json:"type"`
			Name string `json:"name"`
			Text struct {
				Value string `json:"value"`
			} `json:"text,omitempty"`
			Web struct {
				Url   string `json:"url"`
				Title string `json:"title"`
			} `json:"web,omitempty"`
		} `json:"attrs"`
	} `json:"extattr"`
	Status           int    `json:"status"`
	QrCode           string `json:"qr_code"`
	ExternalPosition string `json:"external_position"`
	ExternalProfile  struct {
		ExternalCorpName string `json:"external_corp_name"`
		WechatChannels   struct {
			Nickname string `json:"nickname"`
			Status   int    `json:"status"`
		} `json:"wechat_channels"`
		ExternalAttr []struct {
			Type int    `json:"type"`
			Name string `json:"name"`
			Text struct {
				Value string `json:"value"`
			} `json:"text,omitempty"`
			Web struct {
				Url   string `json:"url"`
				Title string `json:"title"`
			} `json:"web,omitempty"`
			MiniProgram struct {
				Appid    string `json:"appid"`
				Pagepath string `json:"pagepath"`
				Title    string `json:"title"`
			} `json:"miniprogram,omitempty"`
		} `json:"external_attr"`
	} `json:"external_profile"`
}

UserDetail 用户详情

type UserListResponse

type UserListResponse struct {
	Errcode  int          `json:"errcode"`
	Errmsg   string       `json:"errmsg"`
	UserList []UserDetail `json:"userlist"`
}

UserListResponse 用户详情列表

type UserMarkdownMsg

type UserMarkdownMsg struct {
	Markdown struct {
		Content string `json:"content"`
	} `json:"markdown"`
	// contains filtered or unexported fields
}

UserMarkdownMsg 用户私信Markdown消息参数

type UserTextMsg

type UserTextMsg struct {
	Text struct {
		Content string `json:"content"`
	} `json:"text"`
	// contains filtered or unexported fields
}

UserTextMsg 用户私信文本消息参数

Jump to

Keyboard shortcuts

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