- dingdingapi.NewWithAgentID
- CorpAsyncSend and CorpAsyncSendSimple remove agentID param
This commit is contained in:
@@ -31,29 +31,35 @@ const (
|
||||
)
|
||||
|
||||
type API struct {
|
||||
corpID string
|
||||
token string
|
||||
appID string
|
||||
secret string
|
||||
client *http.Client
|
||||
config *platformapi.APIConfig
|
||||
locker sync.RWMutex
|
||||
agentID int64
|
||||
corpID string
|
||||
token string
|
||||
appID string
|
||||
secret string
|
||||
client *http.Client
|
||||
config *platformapi.APIConfig
|
||||
locker sync.RWMutex
|
||||
|
||||
callbackToken string
|
||||
callbackAESKey []byte
|
||||
}
|
||||
|
||||
func New(corpID, appID, secret string, config ...*platformapi.APIConfig) *API {
|
||||
return NewWithAgentID(0, corpID, appID, secret, config...)
|
||||
}
|
||||
|
||||
func NewWithAgentID(agentID int64, corpID, appID, secret string, config ...*platformapi.APIConfig) *API {
|
||||
curConfig := platformapi.DefAPIConfig
|
||||
if len(config) > 0 {
|
||||
curConfig = *config[0]
|
||||
}
|
||||
return &API{
|
||||
corpID: corpID,
|
||||
appID: appID,
|
||||
secret: secret,
|
||||
client: &http.Client{Timeout: curConfig.ClientTimeout},
|
||||
config: &curConfig,
|
||||
agentID: agentID,
|
||||
corpID: corpID,
|
||||
appID: appID,
|
||||
secret: secret,
|
||||
client: &http.Client{Timeout: curConfig.ClientTimeout},
|
||||
config: &curConfig,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func init() {
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
api = New("ding7ab5687f3784a8db", "ding7iu9cptairtcls0c", "LWrZAFeqUfuVv7n_tc8vPpCAx6PT4CwManx2XCVhJOqGsx2L5XCDuX1sAN_JtvsI")
|
||||
api = NewWithAgentID(239461075, "ding7ab5687f3784a8db", "ding7iu9cptairtcls0c", "LWrZAFeqUfuVv7n_tc8vPpCAx6PT4CwManx2XCVhJOqGsx2L5XCDuX1sAN_JtvsI")
|
||||
api.RetrieveToken()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package dingdingapi
|
||||
|
||||
import "strings"
|
||||
|
||||
func (a *API) CorpAsyncSend(agentID int, userIDList, deptIDList []string, isToAllUser bool, msg map[string]interface{}) (err error) {
|
||||
func (a *API) CorpAsyncSend(userIDList, deptIDList []string, isToAllUser bool, msg map[string]interface{}) (err error) {
|
||||
params := map[string]interface{}{
|
||||
"agent_id": agentID,
|
||||
"agent_id": a.agentID,
|
||||
"msg": msg,
|
||||
}
|
||||
if len(userIDList) > 0 {
|
||||
@@ -20,8 +20,8 @@ func (a *API) CorpAsyncSend(agentID int, userIDList, deptIDList []string, isToAl
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) CorpAsyncSendSimple(agentID int, userID, content string) (err error) {
|
||||
return a.CorpAsyncSend(agentID, []string{userID}, nil, false, map[string]interface{}{
|
||||
func (a *API) CorpAsyncSendSimple(userID, content string) (err error) {
|
||||
return a.CorpAsyncSend([]string{userID}, nil, false, map[string]interface{}{
|
||||
"msgtype": "text",
|
||||
"text": map[string]interface{}{
|
||||
"content": content,
|
||||
|
||||
@@ -3,7 +3,7 @@ package dingdingapi
|
||||
import "testing"
|
||||
|
||||
func TestCorpAsyncSend(t *testing.T) {
|
||||
err := api.CorpAsyncSend(239461075, []string{
|
||||
err := api.CorpAsyncSend([]string{
|
||||
"051063452224284964",
|
||||
}, nil, false, map[string]interface{}{
|
||||
"msgtype": "text",
|
||||
@@ -19,7 +19,7 @@ func TestCorpAsyncSend(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCorpAsyncSendSimple(t *testing.T) {
|
||||
err := api.CorpAsyncSendSimple(239461075, "051063452224284964", `
|
||||
err := api.CorpAsyncSendSimple("051063452224284964", `
|
||||
管理用户列表或角色列表。 Casbinadfs 认为由项目自身来管理用户、角色列表更为合适, 用户通常有他们的密码,但是 Casbin 的设计思想并不是把它作为一个存储密码的容器。 而是存储RBAC方案中用户和角色之间的映射关系。
|
||||
`)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user