edingtalk

package module
v0.0.0-...-5247eb1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 21 Imported by: 0

README

注意事项

Documentation

Index

Constants

View Source
const (
	Addr = "https://oapi.dingtalk.com"
	// https://ding-doc.dingtalk.com/document#/org-dev-guide/obtain-access_token
	ApiGetToken = "/gettoken?appkey=%s&appsecret=%s"
	// https://ding-doc.dingtalk.com/document#/org-dev-guide/userid
	ApiGetUserInfo = "/user/getuserinfo?access_token=%s&code=%s"

	// https://ding-doc.dingtalk.com/document#/org-dev-guide/etaarr
	ApiOauth2SnsAuthorize = "/connect/oauth2/sns_authorize?appid=%s&response_type=code&scope=snsapi_auth&state=%s&redirect_uri=%s"
	// https://ding-doc.dingtalk.com/document#/org-dev-guide/kymkv6
	ApiOauth2Qrconnect = "/connect/qrconnect?appid=%s&response_type=code&scope=snsapi_login&state=%s&redirect_uri=%s"

	// https://ding-doc.dingtalk.com/document#/org-dev-guide/obtain-the-user-information-based-on-the-sns-temporary-authorization
	ApiGetUserInfoByCode = "/sns/getuserinfo_bycode?accessKey=%s&timestamp=%s&signature=%s"
	// https://ding-doc.dingtalk.com/document#/org-dev-guide/get-Userid-By-Unionid
	ApiGetUserIdByUnionId = "/user/getUseridByUnionid?access_token=%s&unionid=%s"
	// https://ding-doc.dingtalk.com/document#/org-dev-guide/get-user-detail
	ApiGetUserDetail = "/user/get?access_token=%s&userid=%s"

	// https://ding-doc.dingtalk.com/document/app/create-a-department-v2
	ApiDepartmentGet = "/topapi/v2/department/get?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/create-a-department-v2
	ApiDepartmentCreate = "/topapi/v2/department/create?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/update-a-department-v2
	ApiDepartmentUpdate = "/topapi/v2/department/update?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/delete-a-department-v2
	ApiDepartmentDelete = "/topapi/v2/department/delete?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/delete-a-department-v2
	ApiDepartmentListsub = "/topapi/v2/department/listsub?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/delete-a-department-v2
	ApiDepartmentList = "/department/list?access_token=%s"

	// https://ding-doc.dingtalk.com/document/app/query-user-details
	ApiUserGet = "/topapi/v2/user/get?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/user-information-creation
	ApiUserCreate = "/topapi/v2/user/create?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/user-information-update
	ApiUserUpdate = "/topapi/v2/user/update?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/user-information-delete
	ApiUserDelete = "/topapi/v2/user/delete?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/query-the-list-of-department-userids
	ApiUserListID = "/topapi/user/listid?access_token=%s"
	// https://ding-doc.dingtalk.com/document/app/queries-the-complete-information-of-a-department-user
	ApiUserList = "/topapi/v2/user/list?access_token=%s"
	// https://developers.dingtalk.com/document/app/asynchronous-sending-of-enterprise-session-messages
	CorpconversationAsyncsendV2 = "/topapi/message/corpconversation/asyncsend_v2?access_token=%s"
)
View Source
const (
	// MsgLink 链接消息
	MsgLink = "link"
	// MsgImage 图片消息
	MsgImage = "image"
	// MsgText 文本消息
	MsgText = "text"
	// MsgVoice 语音消息
	MsgVoice = "voice"
	// MsgFile 文件消息
	MsgFile = "file"
	// MsgOA oa消息
	MsgOA = "oa"
	// MsgMD markdown消息
	MsgMD = "markdown"
	// MsgCard 卡片消息
	MsgCard = "action_card"
)
View Source
const PackageName = "component.edingtalk"

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *config

DefaultConfig 返回默认配置

func IntsJoin

func IntsJoin(a []int, sep string) string

IntsJoin []int{"a","b"} => `"a,b"`

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	OpenAPIResponse
	AccessToken string `json:"access_token"`
	ExpireTime  int64  `json:"expires_in"`
	CreateTime  int64
}

type ActionCard

type ActionCard struct {
	BtnJSONList    *BtnJSONList `json:"btn_json_list,omitempty"`
	SingleURL      string       `json:"single_url,omitempty"`
	BtnOrientation string       `json:"btn_orientation,omitempty"`
	SingleTitle    string       `json:"single_title,omitempty"`
	Markdown       string       `json:"markdown,omitempty"`
	Title          string       `json:"title,omitempty"`
}

type Body

type Body struct {
	FileCount string `json:"file_count,omitempty"`
	Image     string `json:"image,omitempty"`
	Form      *Form  `json:"form,omitempty"`
	Author    string `json:"author,omitempty"`
	Rich      *Rich  `json:"rich,omitempty"`
	Title     string `json:"title,omitempty"`
	Content   string `json:"content,omitempty"`
}

type BtnJSONList

type BtnJSONList struct {
	ActionURL string `json:"action_url,omitempty"`
	Title     string `json:"title,omitempty"`
}

type Component

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

func (*Component) CorpconversationAsyncsendV2

func (c *Component) CorpconversationAsyncsendV2(req CorpconversationAsyncsendV2Req) (CorpconversationAsyncsendV2Res, error)

CorpconversationAsyncsendV2 发送工作通知消息 接口文档: https://developers.dingtalk.com/document/app/asynchronous-sending-of-enterprise-session-messages

func (*Component) DepartmentTree

func (c *Component) DepartmentTree(did int) (*Department, error)

获取部门树,递归查询全部子部门 NOTICE: 只能查询Name,DeptID,CreateDeptGroup,ParentID,SubDeptList字段 接口文档 https://ding-doc.dingtalk.com/document/app/obtain-the-department-list 调试文档 https://open-dev.dingtalk.com/apiExplorer#/jsapi?api=runtime.permission.requestAuthCode

func (*Component) GetAccessToken

func (c *Component) GetAccessToken() (token string, err error)

获取access_token https://ding-doc.dingtalk.com/document#/org-dev-guide/obtain-access_token

func (*Component) Oauth2Qrconnect

func (c *Component) Oauth2Qrconnect(state string) string

func (*Component) Oauth2SnsAuthorize

func (c *Component) Oauth2SnsAuthorize(state string) string

获取跳转地址 https://ding-doc.dingtalk.com/document#/org-dev-guide/etaarr

func (*Component) Oauth2UserInfo

func (c *Component) Oauth2UserInfo(code string) (user UserInfoDetail, err error)

根据code,获取用户信息 todo code state

func (*Component) UserList

func (c *Component) UserList(did, cursor, size int) (*UserListRes, error)

获取部门用户详情,注意size最大为100,超过100钉钉会报错 接口文档 https://ding-doc.dingtalk.com/document/app/update-a-department-v2 调试文档 https://open-dev.dingtalk.com/apiExplorer#/jsapi?api=runtime.permission.requestAuthCode

type Container

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

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

Build ...

type CorpconversationAsyncsendV2Req

type CorpconversationAsyncsendV2Req struct {
	Msg        *Msg   `json:"msg,omitempty"`
	ToAllUser  string `json:"to_all_user,omitempty"`  // 是否发送给企业全部用户
	AgentID    int64  `json:"agent_id,omitempty"`     // 无需传递
	DeptIDList string `json:"dept_id_list,omitempty"` // 接收者的部门id列表,最大列表长度20
	UseridList string `json:"userid_list,omitempty"`  // 接收者的userid列表,最大用户列表长度100(多个用户用逗号间隔)
}

CorpconversationAsyncsendV2Req 具体注释: https://developers.dingtalk.com/document/app/asynchronous-sending-of-enterprise-session-messages

type CorpconversationAsyncsendV2Res

type CorpconversationAsyncsendV2Res struct {
	OpenAPIResponse
	TaskID int64 `json:"task_id"` // 创建的异步发送任务ID
}

type Department

type Department struct {
	DeptId            int          `json:"dept_id,omitempty"`
	Name              string       `json:"name,omitempty"`
	ParentId          int          `json:"parent_id,omitempty"`
	HideDept          bool         `json:"hide_dept,omitempty"`
	DeptPermits       Ints         `json:"dept_permits,omitempty"`
	UserPermits       Strings      `json:"user_permits,omitempty"`
	OuterDept         bool         `json:"outer_dept,omitempty"`
	OuterDeptOnlySelf string       `json:"outer_dept_only_self,omitempty"`
	OuterPermitUsers  Strings      `json:"outer_permit_users,omitempty"`
	OuterPermitDepts  Ints         `json:"outer_permit_depts,omitempty"`
	CreateDeptGroup   bool         `json:"create_dept_group,omitempty"`
	Order             int          `json:"order,omitempty"`
	SourceIdentifier  string       `json:"source_identifier,omitempty"`
	SubDeptList       []Department `json:"sub_dept_list,omitempty"`
}

type DepartmentCreateReq

type DepartmentCreateReq = Department

type DepartmentCreateRes

type DepartmentCreateRes struct {
	OpenAPIResponse
	Result struct {
		DeptId int `json:"dept_id"`
	} `json:"result"`
}

type DepartmentListsubRes

type DepartmentListsubRes struct {
	OpenAPIResponse
	Result []Department `json:"result"`
}

type DepartmentUpdateReq

type DepartmentUpdateReq struct {
	DeptId                int     `json:"dept_id,omitempty"`
	ParentId              *int    `json:"parent_id,omitempty"`
	HideDept              *bool   `json:"hide_dept,omitempty"`
	DeptPermits           *string `json:"dept_permits,omitempty"`
	UserPermits           *string `json:"user_permits,omitempty"`
	CreateDeptGroup       *bool   `json:"create_dept_group,omitempty"`
	Order                 *int    `json:"order,omitempty"`
	Name                  *string `json:"name,omitempty"`
	SourceIdentifier      *string `json:"source_identifier,omitempty"`
	OuterDept             *bool   `json:"outer_dept,omitempty"`
	OuterPermitUsers      *string `json:"outer_permit_users,omitempty"`
	OuterPermitDepts      *string `json:"outer_permit_depts,omitempty"`
	OuterDeptOnlySelf     *string `json:"outer_dept_only_self,omitempty"`
	DeptManagerUseridList *string `json:"dept_manager_userid_list"` // 部门的主管userid列表
	OrgDeptOwner          *string `json:"org_dept_owner"`           // 企业群群主的userid
}

func NewDepartmentUpdateReq

func NewDepartmentUpdateReq(did int) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetCreateDeptGroup

func (d *DepartmentUpdateReq) SetCreateDeptGroup(createDeptGroup bool) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetDeptManagerUseridList

func (d *DepartmentUpdateReq) SetDeptManagerUseridList(deptManagerUseridList string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetDeptPermits

func (d *DepartmentUpdateReq) SetDeptPermits(deptPermits string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetHideDept

func (d *DepartmentUpdateReq) SetHideDept(hideDept bool) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetName

func (*DepartmentUpdateReq) SetOrder

func (d *DepartmentUpdateReq) SetOrder(order int) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetOrgDeptOwner

func (d *DepartmentUpdateReq) SetOrgDeptOwner(orgDeptOwner string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetOuterDept

func (d *DepartmentUpdateReq) SetOuterDept(outerDept bool) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetOuterDeptOnlySelf

func (d *DepartmentUpdateReq) SetOuterDeptOnlySelf(outerDeptOnlySelf string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetOuterPermitDepts

func (d *DepartmentUpdateReq) SetOuterPermitDepts(outerPermitDepts string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetOuterPermitUsers

func (d *DepartmentUpdateReq) SetOuterPermitUsers(outerPermitUsers string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetParentId

func (d *DepartmentUpdateReq) SetParentId(did int) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetSourceIdentifier

func (d *DepartmentUpdateReq) SetSourceIdentifier(name string) *DepartmentUpdateReq

func (*DepartmentUpdateReq) SetUserPermits

func (d *DepartmentUpdateReq) SetUserPermits(userPermits string) *DepartmentUpdateReq

type File

type File struct {
	MediaID string `json:"media_id,omitempty"`
}

type Form

type Form struct {
	Value string `json:"value,omitempty"`
	Key   string `json:"key,omitempty"`
}
type Head struct {
	Bgcolor string `json:"bgcolor,omitempty"`
	Text    string `json:"text,omitempty"`
}

type Ints

type Ints []int

func (Ints) MarshalJSON

func (i Ints) MarshalJSON() ([]byte, error)

MarshalJSON 覆盖[]int 的MarshalJSON()方法

type Link struct {
	PicURL     string `json:"picUrl,omitempty"`
	MessageURL string `json:"messageUrl,omitempty"`
	Text       string `json:"text,omitempty"`
	Title      string `json:"title,omitempty"`
}

type Markdown

type Markdown struct {
	Text  string `json:"text,omitempty"`
	Title string `json:"title,omitempty"`
}

type Msg

type Msg struct {
	Voice      *Voice      `json:"voice,omitempty"`
	Image      *File       `json:"image,omitempty"`
	Oa         *Oa         `json:"oa,omitempty"`
	File       *File       `json:"file,omitempty"`
	ActionCard *ActionCard `json:"action_card,omitempty"`
	Link       *Link       `json:"link,omitempty"`
	Markdown   *Markdown   `json:"markdown,omitempty"`
	Text       *Text       `json:"text,omitempty"`
	Msgtype    string      `json:"msgtype,omitempty"` // 消息类型 必传
}

type Oa

type Oa struct {
	Head         *Head      `json:"head,omitempty"`
	PCMessageURL string     `json:"pc_message_url,omitempty"`
	StatusBar    *StatusBar `json:"status_bar,omitempty"`
	Body         *Body      `json:"body,omitempty"`
	MessageURL   string     `json:"message_url,omitempty"`
}

type Oauth2UserUnionInfo

type Oauth2UserUnionInfo struct {
	Nick                 string `json:"nick"`                     // 用户在钉钉上面的昵称
	UnionId              string `json:"unionid"`                  // 用户在当前开放应用所属企业的唯一标识。
	OpenId               string `json:"openid"`                   // 用户在当前开放应用内的唯一标识。
	MainOrgAuthHighLevel bool   `json:"main_org_auth_high_level"` // 用户主企业是否达到高级认证级别
}

type Oauth2UserUnionInfoResponse

type Oauth2UserUnionInfoResponse struct {
	OpenAPIResponse
	UserInfo Oauth2UserUnionInfo `json:"user_info"`
}

type Oauth2UseridInfo

type Oauth2UseridInfo struct {
	OpenAPIResponse
	UserId      string `json:"userid"`      // 用户userid
	ContactType int    `json:"contactType"` // 联系人类型:	0:表示企业内部员工	1:表示企业外部联系人
}

type OpenAPIResponse

type OpenAPIResponse struct {
	ErrCode   int    `json:"errcode"`
	ErrMsg    string `json:"errmsg"`
	RequestId string `json:"request_id"`
}

func (OpenAPIResponse) String

func (o OpenAPIResponse) String() string

type Option

type Option func(c *Container)

func WithERedis

func WithERedis(redis *eredis.Component) Option

type Rich

type Rich struct {
	Unit string `json:"unit,omitempty"`
	Num  string `json:"num,omitempty"`
}

type StatusBar

type StatusBar struct {
	StatusValue string `json:"status_value,omitempty"`
	StatusBg    string `json:"status_bg,omitempty"`
}

type Strings

type Strings []string

func (Strings) MarshalJSON

func (s Strings) MarshalJSON() ([]byte, error)

MarshalJSON 覆盖[]string 的MarshalJSON()方法

type Text

type Text struct {
	Content string `json:"content,omitempty"`
}

type User

type User struct {
	UserId        string              `json:"userid,omitempty"`
	Name          string              `json:"name,omitempty"`
	Mobile        string              `json:"mobile,omitempty"`
	HideMobile    bool                `json:"hide_mobile,omitempty"`
	Telephone     string              `json:"telephone,omitempty"`
	JobNumber     string              `json:"job_number,omitempty"`
	Title         string              `json:"title,omitempty"`
	Email         string              `json:"email,omitempty"`     // 员工私人邮箱
	OrgEmail      string              `json:"org_email,omitempty"` // 员工企业邮箱
	WorkPlace     string              `json:"work_place,omitempty"`
	Remark        string              `json:"remark,omitempty"`
	DeptIdList    Ints                `json:"dept_id_list,omitempty"`
	DeptOrderList []UserDeptOrderList `json:"dept_order_list,omitempty"`
	DeptTitleList []UserDeptTitleList `json:"dept_title_list,omitempty"`
	SeniorMode    bool                `json:"senior_mode,omitempty"`
	HiredDate     int64               `json:"hired_date,omitempty"`
}

type UserCreateReq

type UserCreateReq = User

type UserDeptOrderList

type UserDeptOrderList struct {
	DeptId int `json:"dept_id"`
	Order  int `json:"order"`
}

type UserDeptTitleList

type UserDeptTitleList struct {
	DeptId int `json:"dept_id"`
	Title  int `json:"title"`
}

type UserInfo

type UserInfo struct {
	OpenAPIResponse
	UserId   string `json:"userid"`
	Name     string `json:"name"`
	DeviceId string `json:"deviceId"`
	IsSys    bool   `json:"is_sys"`
	SysLevel int    `json:"sys_level"`
}

type UserInfoDetail

type UserInfoDetail struct {
	OpenAPIResponse
	UserID          string `json:"userid"`
	OpenID          string `json:"openid"`
	Name            string `json:"name"`
	Tel             string
	WorkPlace       string
	Remark          string
	Mobile          string
	Email           string `json:"email"`
	OrgEmail        string
	Active          bool
	IsAdmin         bool
	IsBoos          bool
	DingID          string
	UnionID         string
	IsHide          bool
	Department      []int  `json:"department"`
	Position        string `json:"position"`
	Avatar          string `json:"avatar"`
	Jobnumber       string `json:"jobnumber"`
	IsSenior        bool
	StateCode       string
	OrderInDepts    string
	IsLeaderInDepts string
	Extattr         interface{}
}

type UserListRes

type UserListRes struct {
	HasMore    bool   `json:"has_more"`
	NextCursor int    `json:"next_cursor"`
	List       []User `json:"list"`
}

type UserUpdateReq

type UserUpdateReq struct {
	UserId        string               `json:"userid,omitempty"`
	Name          *string              `json:"name,omitempty"`
	Mobile        *string              `json:"mobile,omitempty"`
	HideMobile    *bool                `json:"hide_mobile,omitempty"`
	Telephone     *string              `json:"telephone,omitempty"`
	JobNumber     *string              `json:"job_number,omitempty"`
	Title         *string              `json:"title,omitempty"`
	Email         *string              `json:"email,omitempty"`     // 员工私人邮箱
	OrgEmail      *string              `json:"org_email,omitempty"` // 员工企业邮箱
	WorkPlace     *string              `json:"work_place,omitempty"`
	Remark        *string              `json:"remark,omitempty"`
	DeptIdList    *Ints                `json:"dept_id_list,omitempty"`
	DeptOrderList *[]UserDeptOrderList `json:"dept_order_list,omitempty"`
	DeptTitleList *[]UserDeptTitleList `json:"dept_title_list,omitempty"`
	SeniorMode    *bool                `json:"senior_mode,omitempty"`
	HiredDate     *int64               `json:"hired_date,omitempty"`
}

func NewUserUpdateReq

func NewUserUpdateReq(uid string) *UserUpdateReq

func (*UserUpdateReq) SetDeptIdList

func (u *UserUpdateReq) SetDeptIdList(deptIdList []int) *UserUpdateReq

func (*UserUpdateReq) SetDeptOrderList

func (u *UserUpdateReq) SetDeptOrderList(deptOrderList []UserDeptOrderList) *UserUpdateReq

func (*UserUpdateReq) SetDeptTitleList

func (u *UserUpdateReq) SetDeptTitleList(deptTitleList []UserDeptTitleList) *UserUpdateReq

func (*UserUpdateReq) SetEmail

func (u *UserUpdateReq) SetEmail(email string) *UserUpdateReq

func (*UserUpdateReq) SetHideMobile

func (u *UserUpdateReq) SetHideMobile(hideMobile bool) *UserUpdateReq

func (*UserUpdateReq) SetHiredDate

func (u *UserUpdateReq) SetHiredDate(hiredDate int64) *UserUpdateReq

func (*UserUpdateReq) SetJobNumber

func (u *UserUpdateReq) SetJobNumber(jobNumber string) *UserUpdateReq

func (*UserUpdateReq) SetMobile

func (u *UserUpdateReq) SetMobile(mobile string) *UserUpdateReq

func (*UserUpdateReq) SetName

func (u *UserUpdateReq) SetName(name string) *UserUpdateReq

func (*UserUpdateReq) SetOrgEmail

func (u *UserUpdateReq) SetOrgEmail(orgEmail string) *UserUpdateReq

func (*UserUpdateReq) SetRemark

func (u *UserUpdateReq) SetRemark(remark string) *UserUpdateReq

func (*UserUpdateReq) SetSeniorMode

func (u *UserUpdateReq) SetSeniorMode(seniorMode bool) *UserUpdateReq

func (*UserUpdateReq) SetTelephone

func (u *UserUpdateReq) SetTelephone(telephone string) *UserUpdateReq

func (*UserUpdateReq) SetTitle

func (u *UserUpdateReq) SetTitle(title string) *UserUpdateReq

func (*UserUpdateReq) SetWorkPlace

func (u *UserUpdateReq) SetWorkPlace(workPlace string) *UserUpdateReq

type Voice

type Voice struct {
	Duration string `json:"duration,omitempty"`
	MediaID  string `json:"media_id,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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