You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
package feishu
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"go.dtapp.net/library/gorequest"
|
|
)
|
|
|
|
type WebhookSendResponse struct {
|
|
Errcode int64 `json:"errcode"`
|
|
Errmsg string `json:"errmsg"`
|
|
Type string `json:"type"`
|
|
MediaId string `json:"media_id"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
type WebhookSendResult struct {
|
|
Result WebhookSendResponse // 结果
|
|
Body []byte // 内容
|
|
Http gorequest.Response // 请求
|
|
Err error // 错误
|
|
}
|
|
|
|
func NewWebhookSendResult(result WebhookSendResponse, body []byte, http gorequest.Response, err error) *WebhookSendResult {
|
|
return &WebhookSendResult{Result: result, Body: body, Http: http, Err: err}
|
|
}
|
|
|
|
// WebhookSend https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN
|
|
func (app *App) WebhookSend(notMustParams ...Params) *WebhookSendResult {
|
|
// 参数
|
|
params := app.NewParamsWith(notMustParams...)
|
|
// 请求
|
|
request, err := app.request(fmt.Sprintf("https://open.feishu.cn/open-apis/bot/v2/hook/%s", app.key), params)
|
|
// 定义
|
|
var response WebhookSendResponse
|
|
err = json.Unmarshal(request.ResponseBody, &response)
|
|
return NewWebhookSendResult(response, request.ResponseBody, request, err)
|
|
}
|