dingtalk

package module
v0.0.0-...-85301ac Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

README

dingtalk

License ci codecov GitHub commit activity (branch) issues GitHub milestone tag

创建和配置应用 先有应用我们才能一起玩

dingtalk 是基于新版的 钉钉开发平台api文档 开发,也就是说在你使用之前是需要在钉钉开发者后台 创建一个小程序或应用

为什么有它

首先我要感谢 godingtalk 库,我是参考他的代码写的。但是由于钉钉历史原因,很多api都更新了,其次就是我有很多钉钉预警的业务需要做,于是就写了这个

怎么使用

go get github.com/zhaoyunxing92/dingtalk/v2
client := NewClient(1244553273, "appkey", "AppSecret")
// 获取token
token, _ := client.GetAccessToken()

fmt.Println(token)

日志级别设置

client:= NewClient(1244553273, "appkey", "AppSecret", WithLevel(zap.DebugLevel))

isv和企业内部开发切换

NewClient的时候如果调用了WithTicketWithCorpId则判定为是isv

一个api的诞生过程

dingtalk.go文件里面已经对网络请求封装好了所以写起来会方便很多,下面从简单的 创建用户 说起

安装工具

格式import的
go get -u github.com/dubbogo/tools/cmd/imports-formatter@v1.0.7
添加license
go get -u github.com/lsm-dev/license-header-checker/cmd/license-header-checker@v1.2.0

request目录下创建一个文件create_user.go

按照文档写参数,注意如果遇到参数校验可以使用validate tag标记

response目录里面也创建一个文件create_user.go必须包含Response结构体

type CreateUser struct {
Response
createUserResponse `json:"result"`
}

type createUserResponse struct {
UserId string `json:"userid"`
}

文件添加license

license-header-checker -v -a -r -i vendor,license-header-checker,tools ./header/license_header.txt . go

格式化import

imports-formatter

参考文档

dingtalk-callback-Crypto

开发进度

main

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(id int, key, secret string, opts ...OptionFunc) (ding *dingTalk)

NewClient new DingTalkBuilder

Types

type OptionFunc

type OptionFunc func(*dingTalk)

func WithCorpId

func WithCorpId(corpId string) OptionFunc

func WithLevel

func WithLevel(level zapcore.Level) OptionFunc

func WithSSOSecret

func WithSSOSecret(secret string) OptionFunc

func WithTicket

func WithTicket(ticket string) OptionFunc

type Robot

type Robot struct {
	Token string
	// contains filtered or unexported fields
}

func (*Robot) SendRobotMsg

func (robot *Robot) SendRobotMsg(req domain.Request) (res domain.Response, err error)

SendRobotMsg:机器人发送消息

Jump to

Keyboard shortcuts

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