Skip to content

Commit

Permalink
Merge pull request #423 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Matrix-X committed Dec 23, 2023
2 parents 53ba90e + d83f796 commit 1bb3728
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/work/externalContact/moment/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/externalContact/moment/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/externalContact/moment/response"
)
Expand Down Expand Up @@ -101,3 +102,16 @@ func (comp *Client) GetMomentComments(ctx context.Context, momentID string, user

return result, err
}

// 企业发表内容到客户的朋友圈
// https://developer.work.weixin.qq.com/document/path/95095
func (comp *Client) AddMomentTask(ctx context.Context, params *request.RequestAddMomentTask) (*response.ResponseAddMomentTask, error) {

result := &response.ResponseAddMomentTask{}

options, _ := power.StructToHashMap(params)

_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/externalcontact/add_moment_task", options, nil, nil, result)

return result, err
}
46 changes: 46 additions & 0 deletions src/work/externalContact/moment/request/requestAddMomentTask.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package request

type ExternalContactList struct {
TagList []string `json:"tag_list"`
}

type SenderList struct {
UserList []string `json:"user_list"`
DepartmentList []int `json:"department_list"`
}

type VisibleRange struct {
SenderList SenderList `json:"sender_list"`
ExternalContactList ExternalContactList `json:"external_contact_list"`
}

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

type Image struct {
MediaId string `json:"media_id"`
}

type Link struct {
Title string `json:"title"`
Url string `json:"url"`
MediaId string `json:"media_id"`
}

type Video struct {
MediaId string `json:"media_id"`
}

type Attachment struct {
Msgtype string `json:"msgtype"`
Image Image `json:"image,omitempty"`
Video Video `json:"video,omitempty"`
Link Link `json:"link,omitempty"`
}

type RequestAddMomentTask struct {
Text Text `json:"text"`
Attachments []Attachment `json:"attachments"`
VisibleRange *VisibleRange `json:"visible_range"`
}
26 changes: 26 additions & 0 deletions src/work/externalContact/moment/response/responseAddMomentTask.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package response

import "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"

type InvalidSenderList struct {
UserList []string `json:"user_list"`
DepartmentList []int `json:"department_list"`
}

type InvalidExternalContactList struct {
TagList []string `json:"tag_list"`
}

type Result struct {
response.ResponseWork
MomentId string `json:"moment_id"`
InvalidSenderList InvalidSenderList `json:"invalid_sender_list"`
InvalidExternalContactList InvalidExternalContactList `json:"invalid_external_contact_list"`
}

type ResponseAddMomentTask struct {
response.ResponseWork
Status int `json:"status"`
Type string `json:"type"`
Result Result `json:"result"`
}

0 comments on commit 1bb3728

Please sign in to comment.