wxpusher

package
v0.0.0-...-cdc315d Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ContentHtml = contentType(2)
View Source
const ContentMarkdown = contentType(3)
View Source
const ContentText = contentType(1)
View Source
const UrlBase = "http://wxpusher.zjiecode.com"
View Source
const UrlMessageStatus = UrlBase + "/api/send/query/${messageId}"
View Source
const UrlSendMessage = UrlBase + "/api/send/message"

Variables

This section is empty.

Functions

func NewBusinessError

func NewBusinessError(err error) error

NewBusinessError 创建业务异常

func NewError

func NewError(code int, err error) error

NewError 创建新的异常

func VerifyMessage

func VerifyMessage(message Message) error

VerifyMessage 消息参数验证

Types

type Error

type Error struct {
	Code  int
	Title string
	Cause error
}

func (Error) Error

func (err Error) Error() string

type Message

type Message struct {
	AppToken    string      `json:"appToken"`
	Content     string      `json:"content"`
	ContentType contentType `json:"contentType"`
	TopicIds    []int       `json:"topicIds"`
	UIds        []string    `json:"uids"`
	Url         string      `json:"url"`
}

Message 消息结构体

func NewMessage

func NewMessage(appToken string) *Message

func (*Message) AddTopicId

func (m *Message) AddTopicId(id int, more ...int) *Message

func (*Message) AddUId

func (m *Message) AddUId(id string, more ...string) *Message

func (Message) Send

func (m Message) Send() (SendResult, error)

func (*Message) SetContent

func (m *Message) SetContent(content string) *Message

func (*Message) SetContentType

func (m *Message) SetContentType(ct contentType) *Message

func (*Message) SetUrl

func (m *Message) SetUrl(url string) *Message

type QueryResult

type QueryResult struct {
	Code    int    `json:"code"`
	Msg     string `json:"msg"`
	Data    int    `json:"data"`
	Success bool   `json:"success"`
}

func QueryMessageStatus

func QueryMessageStatus(messageId int) (QueryResult, error)

QueryMessageStatus 查询消息发送状态

func (*QueryResult) Error

func (result *QueryResult) Error() error

type SendResult

type SendResult struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data []struct {
		Uid       string `json:"uid"`
		TopicId   string `json:"topicId"`
		MessageId int    `json:"messageId"`
		Code      int    `json:"code"`
		Status    string `json:"status"`
	} `json:"data"`
	Success bool `json:"success"`
}

SendResult

func SendMessage

func SendMessage(message Message) (SendResult, error)

SendMessage 发送消息

func (*SendResult) Error

func (result *SendResult) Error() error

Error 判断结果是否异常

Jump to

Keyboard shortcuts

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