wechatwork

package
v0.0.0-...-9b96405 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const APIErrAccessTokenNotLast = 40001
View Source
const APIErrAccessTokenOutOfDate = 42001
View Source
const APIErrAccessTokenWrong = 40014
View Source
const APIErrNoPrivilege = 60011
View Source
const APIErrOauthCodeWrong = 40029
View Source
const APIErrSuccess = 0
View Source
const APIErrUserUnaccessible = 50002
View Source
const APIResultGenderFemale = "2"
View Source
const APIResultGenderMale = "1"
View Source
const MediaTypeFile = MediaType("file")
View Source
const MediaTypeImage = MediaType("image")
View Source
const MediaTypeVideo = MediaType("video")
View Source
const MediaTypeVoice = MediaType("voice")
View Source
const MsgTypeFile = "file"
View Source
const MsgTypeImage = "image"
View Source
const MsgTypeMPNews = "mpnews"
View Source
const MsgTypeMarkdown = "markdown"
View Source
const MsgTypeNews = "news"
View Source
const MsgTypeTaskcard = "taskcard"
View Source
const MsgTypeText = "text"
View Source
const MsgTypeTextcard = "textcard"
View Source
const MsgTypeVideo = "video"
View Source
const MsgTypeVoice = "voice"

Variables

View Source
var Server = fetcher.MustPreset(&fetcher.ServerInfo{
	URL: "https://qyapi.weixin.qq.com",
})

Functions

func NewResultError

func NewResultError(code int, msg string) error

Types

type Agent

type Agent struct {
	CorpID          string
	AgentID         int
	Secret          string
	RemoteRefresher *fetcher.Server
	Client          fetcher.Client
	// contains filtered or unexported fields
}

func (*Agent) AccessToken

func (a *Agent) AccessToken() (string, error)

func (*Agent) CallJSONApiWithAccessToken

func (a *Agent) CallJSONApiWithAccessToken(api *fetcher.Preset, params url.Values, body interface{}, v interface{}) error

func (*Agent) ClientCredentialBuilder

func (a *Agent) ClientCredentialBuilder() fetcher.Command

func (*Agent) GetAccessToken

func (a *Agent) GetAccessToken() (string, error)

func (*Agent) GetDepartmentList

func (a *Agent) GetDepartmentList(id string) (*[]DepartmentInfo, error)

func (*Agent) GetUserInfo

func (a *Agent) GetUserInfo(code string) (*Userinfo, error)

func (*Agent) GrantAccessToken

func (a *Agent) GrantAccessToken() (string, error)

func (*Agent) MediaUpload

func (a *Agent) MediaUpload(mediatype MediaType, filename string, body io.Reader) (string, error)

func (*Agent) NewMessage

func (a *Agent) NewMessage() *Message

func (*Agent) RefreshShared

func (a *Agent) RefreshShared(old []byte) ([]byte, error)

RefreshShared refresh shared data. New data what different from old should be returned

func (*Agent) SendMessage

func (a *Agent) SendMessage(b *Message) (*MessageResult, error)

func (*Agent) SetAccessTokenGetter

func (a *Agent) SetAccessTokenGetter(f func() (string, error))

func (*Agent) SetAccessTokenRefresher

func (a *Agent) SetAccessTokenRefresher(f func(string) (string, error))

func (*Agent) UploadApiWithAccessToken

func (a *Agent) UploadApiWithAccessToken(api *fetcher.Preset, params url.Values, filename string, body io.Reader, v interface{}) error

type DepartmentInfo

type DepartmentInfo struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ParentID int    `json:"parentid"`
	Order    int    `json:"order"`
}

type MediaType

type MediaType string

type Message

type Message struct {
	ToUser   *string          `json:"touser"`
	ToParty  *string          `json:"toparty"`
	ToTag    *string          `json:"totag"`
	MsgType  string           `json:"msgtype"`
	AgentID  int              `json:"agentid"`
	Safe     int              `json:"safe"`
	Text     *MessageText     `json:"text"`
	Image    *MessageMedia    `json:"image"`
	Voice    *MessageMedia    `json:"voice"`
	File     *MessageMedia    `json:"file"`
	Video    *MessageVideo    `json:"video"`
	News     *MessageNews     `json:"news"`
	MPNews   *MessageMPNews   `json:"mpnews"`
	Textcard *MessageTextcard `json:"textcard"`
	Taskcard *MessageTaskcard `json:"taskcard"`
	Markdown *MessageMarkdown `json:"markdown"`
}

func NewMessage

func NewMessage() *Message

func (*Message) SetMsgType

func (p *Message) SetMsgType(MsgType string)

func (*Message) SetToParty

func (p *Message) SetToParty(parties ...string)

func (*Message) SetToTag

func (p *Message) SetToTag(tags ...string)

func (*Message) SetToUser

func (p *Message) SetToUser(users ...string)

type MessageArticle

type MessageArticle struct {
	Title       *string `json:"title"`
	Description *string `json:"description"`
	URL         *string `json:"url"`
	PicURL      *string `json:"picurl"`
}

type MessageMPArticle

type MessageMPArticle struct {
	Title            string  `json:"title"`
	ThumbMediaID     string  `json:"thumb_media_id"`
	ContentSourceUrl *string `json:"content_source_url"`
	Content          *string `json:"content"`
	Digest           *string `json:"digest"`
}

type MessageMPNews

type MessageMPNews struct {
	Articles []*MessageMPArticle `json:"articles"`
}

type MessageMarkdown

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

type MessageMedia

type MessageMedia struct {
	MediaID string `json:"media_id"`
}

type MessageNews

type MessageNews struct {
	Articles []*MessageArticle `json:"articles"`
}

type MessageResult

type MessageResult struct {
	Errcode      int    `json:"errcode"`
	Errmsg       string `json:"errmsg"`
	InvalidUser  string `json:"invaliduser"`
	InvalidParty string `json:"invalidparty"`
	InvalidTag   string `json:"invalidtag"`
}

type MessageTaskcard

type MessageTaskcard struct {
	Title       string                `json:"title"`
	Description string                `json:"description"`
	URL         *string               `json:"url"`
	TaskID      string                `json:"task_id"`
	Btn         []*MessageTaskcardBtn `json:"btn"`
}

type MessageTaskcardBtn

type MessageTaskcardBtn struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	ReplaceName string `json:"replace_name"`
	Color       string `json:"color"`
	IsBold      bool   `json:"is_bold"`
}

type MessageText

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

type MessageTextcard

type MessageTextcard struct {
	Title       string  `json:"title"`
	Description string  `json:"description"`
	URL         string  `json:"url"`
	Btntxt      *string `json:"btntxt"`
}

type MessageVideo

type MessageVideo struct {
	MediaID     string  `json:"media_id"`
	Title       *string `json:"title"`
	Description *string `json:"description"`
}

type Userinfo

type Userinfo struct {
	UserID     string
	Name       string
	Mobile     string
	Email      string
	Gender     string
	Avatar     string
	Department []int
}

Jump to

Keyboard shortcuts

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