1 Star 0 Fork 0

liuliang/jpush-api-golang-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cid.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
liuliang 提交于 2022-11-09 13:44 +08:00 . init
package jpush
import (
"encoding/json"
"fmt"
)
type CidRequest struct {
Count int `json:"count,omitempty"` // 数值类型,不传则默认为 1。范围为 [1, 1000]
Type string `json:"type,omitempty"` // CID 类型。取值:push(默认),schedule
}
type CidResponse struct {
CidList []string `json:"cidlist,omitempty"` // CID 列表
}
func (c CidRequest) String() string {
return fmt.Sprintf("CidRequest{Count: %d, Type: %s}", c.Count, c.Type)
}
func (c CidResponse) String() string {
return fmt.Sprintf("CidResponse{CidList: %v}", c.CidList)
}
// NewCidRequest 创建 CidRequest 对象
func NewCidRequest(count int, push_type string) *CidRequest {
c := &CidRequest{}
if count <= 0 || count > 1000 {
c.Count = 1
} else {
c.Count = count
}
if push_type == "" {
c.Type = "push"
} else {
c.Type = push_type
}
return c
}
// GetCidList 获取 CID 列表
func (c *CidRequest) GetCidList(key, secret string) (*CidResponse, error) {
resp := &CidResponse{}
jc := NewJPushClient(key, secret)
data, err := jc.GetCid(c.Count, c.Type)
if err != nil {
return nil, err
}
fmt.Printf("%+v\n", string(data))
err = json.Unmarshal(data, resp)
return resp, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dashiqiao/jpush-api-golang-client.git
git@gitee.com:dashiqiao/jpush-api-golang-client.git
dashiqiao
jpush-api-golang-client
jpush-api-golang-client
v1.0.1

搜索帮助