getui

package module
v0.0.0-...-f095387 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 8 Imported by: 0

README

getui sdk for golang

!!! 因工作变动,已经不再更新,有需要可以私信我帮忙。原有功能依旧能用

目前最新版本 1.0.0

安装

    go get github.com/printfcoder/getui

鉴于GeTui 官网没有提供Golang的sdk包,这里简单封装一下常用的推送功能。封装采用单例模式

目前功能有:鉴权,单发,app推,终止群推,查询用户状态,tolist推

未来{2017年5月25日后}

将持续开发:批量单推,别名功能,标签管理,黑名单用户管理,其它推送结果与用户查询功能

重要说明

除初始化外,Appkey的设置将无效。 如何使用: 见tests目录下的各用例。

特别说明

对于所有推送请求,均采用post方式,个推会返回taskid,我会把它封装在rspBody中,供后续调用

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppReqBody

type AppReqBody struct {
	Message      Message               `json:"message"`
	Notification Notification          `json:"notification"`
	Condition    []AppReqBodyCondition `json:"condition"`
	RequestID    string                `json:"requestid"`
}

AppReqBody 个推请求body toapp 参考资料 http://docs.getui.com/server/rest/push/#5-toapp

type AppReqBodyCondition

type AppReqBodyCondition struct {
	Key     string   `json:"key"`
	Values  []string `json:"values"`
	OptType string   `json:"opt_type"`
}

AppReqBodyCondition toapp 过滤条件 参考资料 http://docs.getui.com/server/rest/push/#5-toapp

type Client

type Client interface {
	PushToSingle(SingleReqBody) (*RspBody, error)
	PushToList(ListReqBody) (*RspBody, error)
	PushToApp(AppReqBody) (*RspBody, error)
	StopTask(string) (*RspBody, error)
	UserStatus(string) (*UserStatus, error)
	CloseAuth() (*RspBody, error)
	UserExisted(string) (bool, error)
	AuthToken() string
}

Client 客户端接口

func Init

func Init(parms InitParams) (c Client, err error)

Init 客户端-单例

type InitParams

type InitParams struct {
	AppID        string
	AppSecret    string
	AppKey       string
	MasterSecret string
	// AuthHeartbeat Auth刷新时间 单位小时 默认20小时
	AuthHeartbeat time.Duration
}

InitParams 初始化参数

type ListReqBody

type ListReqBody struct {
	Message           Message      `json:"message"`
	Notification      Notification `json:"notification"`
	CID               []string     `json:"cid,omitempty"`
	Alias             string       `json:"alias,omitempty"`
	PushInfo          PushInfo     `json:"push_info"`
	TaskID            string       `json:"taskid"`
	NeedDetail        bool         `json:"need_detail"`
	OfflineExpireTime int64        `json:"-"`
}

ListReqBody 个推请求body list 参考资料 http://docs.getui.com/server/rest/push/#4-tolist

type Message

type Message struct {
	AppKey    string `json:"appkey"`
	IsOffline bool   `json:"is_offline"`
	MsgType   string `json:"msgtype"`
}

Message 请求消息配置 Message

type Notification

type Notification struct {
	Style struct {
		Type      int    `json:"type"`
		Text      string `json:"text"`
		Title     string `json:"title"`
		Logo      string `json:"logo"`
		IsRing    bool   `json:"is_ring"`
		IsVibrate bool   `json:"is_vibrate"`
	} `json:"style"`
	TransmissionType    bool   `json:"transmission_type"`
	TransmissionContent string `json:"transmission_content"`
}

Notification 请求消息配置 Notification 资料 http://docs.getui.com/server/rest/template/

type PushInfo

type PushInfo struct {
	Aps struct {
		Alert struct {
			Title string `json:"title,omitempty"`
			Body  string `json:"body,omitempty"`
		} `json:"alert"`
		AutoBadge        string `json:"autoBadge,omitempty"`
		ContentAvailable int    `json:"content-available,omitempty"`
	} `json:"aps"`

	Multimedia []PushInfoMultimedia `json:"multimedia,omitempty"`
}

PushInfo 推送信息

type PushInfoMultimedia

type PushInfoMultimedia struct {
	URL      string `json:"url,omitempty"`
	Type     int    `json:"type,omitempty"`
	OnlyWifi bool   `json:"only_wifi,omitempty"`
}

PushInfoMultimedia 推送消息多媒体信息

type RspBody

type RspBody struct {
	Result    string `json:"result"`
	TaskID    string `json:"taskid"`
	Desc      string `json:"desc"`
	Status    string `json:"status"`
	RequestID string `json:"requestID,omitempty"`
}

RspBody 个推Rsp body 个推请求返回的结构 status : successed_offline 离线下发

successed_online 在线下发
successed_ignore 非活跃用户不下发

type SaveListBody

type SaveListBody struct {
	Message      saveListBodymessage `json:"message"`
	Notification Notification        `json:"notification"`
}

SaveListBody 保存消息共同体 list推时有需要先把消息共同体保存到个推,再发送推送到客户端的请求

type SingleReqBody

type SingleReqBody struct {
	Message      Message      `json:"message"`
	Notification Notification `json:"notification"`
	CID          string       `json:"cid,omitempty"`
	Alias        string       `json:"alias,omitempty"`
	RequestID    string       `json:"requestid"`
	PushInfo     PushInfo     `json:"push_info"`
}

SingleReqBody 个推请求body 单推 参考资料 http://docs.getui.com/server/rest/push/#3

type UserStatus

type UserStatus struct {
	Result        string `json:"result"`
	CID           string `json:"cid"`
	Status        string `json:"status"`
	LastLoginUnix string `json:"lastlogin"`
	LastLogin     time.Time
}

UserStatus 用户状态 rsp body

Jump to

Keyboard shortcuts

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