push

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host        string = "https://msgapi.umeng.com"
	SendPath    string = "/api/send"
	StatusPath  string = "/api/status"
	ChannelPath string = "/api/channel/data"
	QuotaPath   string = "/api/quota/query"
	CancelPath  string = "/api/cancel"
	UploadPath  string = "/upload"

	TagAddPath    string = "/api/tag/add"
	TagListPath   string = "/api/tag/list"
	TagSetPath    string = "/api/tag/set"
	TagDeletePath string = "/api/tag/delete"
	TagClearPath  string = "/api/tag/clear"

	TmplAddPath    string = "/api/template/add"
	TmplDeletePath string = "/api/template/delete"
	TmplGetPath    string = "/api/template/get"
	TmplListPath   string = "/api/template/list"
	TmplSendPath   string = "/api/template/send"
	TmplMsgPath    string = "/api/template/msg"

	IOS     string = "ios"
	Android string = "android"
)

Variables

View Source
var Proxy string

Functions

func NewUmengError

func NewUmengError(code int, msg string) error

Types

type AddTemplateResp

type AddTemplateResp struct {
	Ret  string `json:"ret"`
	Data struct {
		TemplateKeys []string `json:"template_keys"`
		TemplateId   string   `json:"template_id"`
	} `json:"data"`
}

type App

type App struct {
	AppKey       string
	MasterSecret string
	Platform     string
	PackageName  string // 包名(安卓离线推送需要)
	Debug        bool
}

func (*App) AddTag

func (a *App) AddTag(device string, tag string) (err error)

func (*App) AddTags

func (a *App) AddTags(device string, tags []string) (err error)

func (*App) AddTemplate

func (a *App) AddTemplate(template interface{}) (templateId string, err error)

func (*App) Cancel

func (a *App) Cancel(taskId string) (ret CancelResp, err error)

func (*App) Channel

func (a *App) Channel(taskId string) (ret ChannelData, err error)

func (*App) ClearTags

func (a *App) ClearTags(device string) (err error)

func (*App) DeleteTag

func (a *App) DeleteTag(device string, tag string) (err error)

func (*App) DeleteTags

func (a *App) DeleteTags(device string, tags []string) (err error)

func (*App) DeleteTemplate

func (a *App) DeleteTemplate(templateId string) (err error)

func (*App) GetMsg

func (a *App) GetMsg(templateMsgId string, limit int, cursor string) (ret []Msg, last string, err error)

func (*App) GetTemplate

func (a *App) GetTemplate(templateId string) (ret *Template, err error)

func (*App) GetTemplateCount

func (a *App) GetTemplateCount() int

func (*App) ListTags

func (a *App) ListTags(device string) (tags []string, err error)

func (*App) ListTemplate

func (a *App) ListTemplate(page int, limit int) (ret *ListTemplateData, err error)

func (*App) Quota

func (a *App) Quota() (ret QuotaData, err error)

func (*App) Request

func (a *App) Request(uri string, reqBody interface{}) (content []byte, err error)

func (*App) SendTemplateMsg

func (a *App) SendTemplateMsg(templateId string, data []interface{}) (templateMsgId string, err error)

func (*App) SetTags

func (a *App) SetTags(device string, tags []string) (err error)

func (*App) Sign

func (a *App) Sign(url string, body string) string

func (*App) Status

func (a *App) Status(taskId string) (ret StatusData, err error)

func (*App) Upload

func (a *App) Upload(content string) (fileId string, err error)

func (*App) UploadFile

func (a *App) UploadFile(file string) (fileId string, err error)

type CancelReq

type CancelReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
	TaskId    string `json:"task_id"`
}

type CancelResp

type CancelResp struct {
	Ret  string `json:"ret"`
	Data struct {
		TaskId string `json:"task_id"`
	} `json:"data"`
}

type ChannelData

type ChannelData struct {
	Stats []struct {
		Channel            string       `json:"channel"`
		ChannelArriveCount int          `json:"channel_arrive_count"`
		ChannelClick       int          `json:"channel_click"`
		ChannelSentCount   int          `json:"channel_sent_count"`
		Errors             []ChannelErr `json:"errors"`
	} `json:"stats"`
}

type ChannelErr

type ChannelErr struct {
	ErrorCode string `json:"error_code"`
	ErrorInfo string `json:"error_info"`
	Num       string `json:"num"`
}

type ChannelReq

type ChannelReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
	TaskId    string `json:"task_id"`
}

type ChannelResp

type ChannelResp struct {
	Ret  string      `json:"ret"`
	Data ChannelData `json:"data"`
}

type ListTemplateData

type ListTemplateData struct {
	Next  bool       `json:"next"`
	Pre   bool       `json:"pre"`
	Total int        `json:"total"`
	Len   int        `json:"len"`
	Index int        `json:"index"`
	List  []Template `json:"list"`
}

type ListTemplateReq

type ListTemplateReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
	Index     int    `json:"index"`
	Len       int    `json:"len"`
}

type ListTemplateResp

type ListTemplateResp struct {
	Ret  string           `json:"ret"`
	Data ListTemplateData `json:"data"`
}

type Msg

type Msg struct {
	Appkey        string `json:"appkey"`
	Index         int    `json:"index"`
	MsgId         string `json:"msgId"`
	Params        string `json:"params"`
	TemplateId    string `json:"templateId"`
	TemplateMsgId string `json:"templateMsgId"`
}

type MsgReq

type MsgReq struct {
	Appkey        string `json:"appkey"`
	Timestamp     int64  `json:"timestamp"`
	TemplateMsgId string `json:"template_msg_id"`
	StartKey      string `json:"start_key,omitempty"`
	Len           int    `json:"len"`
}

type MsgResp

type MsgResp struct {
	Ret  string `json:"ret"`
	Data struct {
		List []Msg `json:"list"`
	} `json:"data"`
}

type QuotaData

type QuotaData struct {
	VivoSysMsgCount    string `json:"vivoSysMsgCount"`
	XmAckedCount       string `json:"xmAckedCount"`
	OppoTotalCount     string `json:"oppoTotalCount"`
	XmQuotaCount       string `json:"xmQuotaCount"`
	OppoPushCount      string `json:"oppoPushCount"`
	VivoMarketMsgCount string `json:"vivoMarketMsgCount"`
	OppoRemainCount    string `json:"oppoRemainCount"`
}

type QuotaReq

type QuotaReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
}

type QuotaResp

type QuotaResp struct {
	Ret  string    `json:"ret"`
	Data QuotaData `json:"data"`
}

type SendTemplateMsgReq

type SendTemplateMsgReq struct {
	Appkey     string        `json:"appkey"`
	Timestamp  int64         `json:"timestamp"`
	TemplateId string        `json:"template_id"`
	ParamsData []interface{} `json:"params_data"`
}

type SendTemplateMsgResp

type SendTemplateMsgResp struct {
	Ret  string `json:"ret"`
	Data struct {
		TemplateMsgId string `json:"template_msg_id"`
	} `json:"data"`
}

type StatusData

type StatusData struct {
	TaskId       string `json:"task_id"`
	Status       int64  `json:"status"`        // 消息状态:0排队中 1发送中 2发送完成 3发送失败 4消息被撤销 5消息过期 6筛选结果为空 7定时任务尚未开始处理
	OpenCount    int64  `json:"open_count"`    // android/ios共有:打开数
	SentCount    int64  `json:"sent_count"`    // android/ios共有:消息收到数(android) APNs返回SUCCESS的设备数(ios)
	DismissCount int64  `json:"dismiss_count"` // android特有:忽略数
	TotalCount   int64  `json:"total_count"`   // ios特有:投递APNs设备数
}

type StatusReq

type StatusReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
	TaskId    string `json:"task_id"`
}

type StatusResp

type StatusResp struct {
	Ret  string     `json:"ret"`
	Data StatusData `json:"data"`
}

type Template

type Template struct {
	TemplateName string `json:"template_name"`
	TemplateInfo string `json:"template_info"`
	TemplateKeys string `json:"template_keys"`
	Appkey       string `json:"appkey"`
	TemplateId   string `json:"template_id"`
	Id           int    `json:"id"`
}

type TemplateReq

type TemplateReq struct {
	Appkey     string `json:"appkey"`
	Timestamp  int64  `json:"timestamp"`
	TemplateId string `json:"template_id"`
}

type TemplateResp

type TemplateResp struct {
	Ret  string   `json:"ret"`
	Data Template `json:"data"`
}

type Umeng

type Umeng struct {
	Android *App
	IOS     *App
}

func NewUmeng

func NewUmeng() *Umeng

func (*Umeng) Debug

func (u *Umeng) Debug(debug bool) *Umeng

func (*Umeng) GetApp

func (u *Umeng) GetApp(platform string) *App

func (*Umeng) InitAndroid

func (u *Umeng) InitAndroid(appkey string, secret string) *Umeng

func (*Umeng) InitIOS

func (u *Umeng) InitIOS(appkey string, secret string) *Umeng

func (*Umeng) SetPackageName

func (u *Umeng) SetPackageName(packageName string) *Umeng

func (*Umeng) UseProxy added in v1.1.0

func (u *Umeng) UseProxy(addr string)

type UmengError

type UmengError struct {
	ErrorCode interface{} `json:"error_code"`
	ErrorMsg  string      `json:"error_msg"`
}

func (*UmengError) Error

func (e *UmengError) Error() string

type UmengErrorResp

type UmengErrorResp struct {
	Ret  string      `json:"ret"`
	Data *UmengError `json:"data"`
}

type UploadReq

type UploadReq struct {
	Appkey    string `json:"appkey"`
	Timestamp int64  `json:"timestamp"`
	Content   string `json:"content"`
}

type UploadResp

type UploadResp struct {
	Ret  string `json:"ret"`
	Data struct {
		FileId string `json:"file_id"`
	} `json:"data"`
}

Directories

Path Synopsis
ios

Jump to

Keyboard shortcuts

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