getuigo

package module
v0.0.0-...-99054d0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 8 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

getuigo

Go Reference Build Status Coverage Status Go Report Card

简介

项目在github.com/geek-go/getui的基础上封装了个推的go语言SDK。 项目定义了Payload数据结构和接口,并且封装了发送流程接口。

数据结构说明
GetuiConfig
type GetuiConfig struct {
     AppId        string `yaml:"appid"`
     AppKey       string `yaml:"appkey"`
     AppSecret    string `yaml:"appsecret"`
     MasterSecret string `yaml:"mastersecret"`
 }

可以通过YAML或者其他方式填充个推的配置,注意请不要将秘钥包含在版本库中。

GetuiPush

GetuiPush是外部调用的数据结构,封装了发送推送的接口。

BasicPayload
type BasicPayload struct {
    PushTitle    string `json:"push_title"`
    PushBody     string `json:"push_body"`
    IsShowNotify int    `json:"is_show_notify"`
    Ext          string `json:"ext"`
}

可以通过组合BasicPayload并实现Payload接口的方式定义属于业务的Payload。

示例

sample 中实现了调用示例。

Documentation

Index

Constants

View Source
const (
	LogNone = iota
	LogStd
	LogFile
)
View Source
const NotifyTypeIntent = "1"
View Source
const NotifyTypePayload = "0"
View Source
const NotifyTypeUrl = "2"

Variables

View Source
var LogType = LogNone

Functions

func IGtTransmissionTemplate

func IGtTransmissionTemplate(payload Payload) (*getui.Transmission, *getui.PushInfo, error)

Types

type BasicPayload

type BasicPayload struct {
	NotifyTitle  string `json:"push_title"`
	NotifyBody   string `json:"push_body"`
	IsShowNotify int    `json:"is_show_notify"`
	Ext          string `json:"ext"`
}

func (*BasicPayload) GetExt

func (p *BasicPayload) GetExt() string

func (*BasicPayload) GetIntent

func (p *BasicPayload) GetIntent() string

func (*BasicPayload) GetIsShowNotify

func (p *BasicPayload) GetIsShowNotify() int

func (*BasicPayload) GetNotifyBody

func (p *BasicPayload) GetNotifyBody() string

func (*BasicPayload) GetNotifyTitle

func (p *BasicPayload) GetNotifyTitle() string

func (*BasicPayload) SetExt

func (p *BasicPayload) SetExt(ext string)

func (*BasicPayload) SetIntent

func (p *BasicPayload) SetIntent(_ string)

func (*BasicPayload) SetIsShowNotify

func (p *BasicPayload) SetIsShowNotify(isshow int)

func (*BasicPayload) SetNotifyBody

func (p *BasicPayload) SetNotifyBody(body string)

func (*BasicPayload) SetNotifyTitle

func (p *BasicPayload) SetNotifyTitle(title string)

func (*BasicPayload) String

func (p *BasicPayload) String() string

type GetuiConfig

type GetuiConfig struct {
	AppId          string `json:"appid" yaml:"appid"`
	AppKey         string `json:"appkey" yaml:"appkey"`
	AppSecret      string `json:"appsecret" yaml:"appsecret"`
	MasterSecret   string `json:"mastersecret" yaml:"mastersecret"`
	IntentTemplate string `json:"intent_template" yaml:"intent_template"`
}

type GetuiPush

type GetuiPush struct {
	Config          *GetuiConfig
	Token           string
	TokenExpires    time.Time
	RequestTokenCnt int
}

func NewGeTui

func NewGeTui(config *GetuiConfig) (*GetuiPush, error)

func (*GetuiPush) GetAuthToken

func (g *GetuiPush) GetAuthToken() (string, error)

func (*GetuiPush) IsAuthTokenValid

func (g *GetuiPush) IsAuthTokenValid() bool

func (*GetuiPush) MergeAppConditions

func (g *GetuiPush) MergeAppConditions(filters ...getui.AppCondition) getui.Condition

func (*GetuiPush) PushAppConditions

func (g *GetuiPush) PushAppConditions(filters ...getui.AppCondition) getui.Condition

func (*GetuiPush) RequestId

func (g *GetuiPush) RequestId(useUuid bool) (s string)

func (*GetuiPush) SendTransmissionByCid

func (g *GetuiPush) SendTransmissionByCid(cid string, payload Payload) error

func (*GetuiPush) SendTransmissionByCidList

func (g *GetuiPush) SendTransmissionByCidList(cids []string, payload Payload) error

func (*GetuiPush) SendTransmissionToAll

func (g *GetuiPush) SendTransmissionToAll(payload Payload, filter ...getui.AppCondition) error

type Payload

type Payload interface {
	GetNotifyTitle() string
	SetNotifyTitle(title string)
	GetNotifyBody() string
	SetNotifyBody(body string)
	GetIsShowNotify() int
	SetIsShowNotify(isshow int)
	GetIntent() string
	SetIntent(intent string)
	String() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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