Skip to content

Commit

Permalink
引入包结构变更
Browse files Browse the repository at this point in the history
  • Loading branch information
dacker-soul committed Jan 21, 2021
1 parent fd4c186 commit 1d1affb
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 93 deletions.
22 changes: 11 additions & 11 deletions push/all/push_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ package all
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 群推参数
type PushAllParam struct {
RequestId string `json:"request_id"` // 必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Audience string `json:"audience"` // 必须字段,必须为all
Settings *Settings `json:"settings"` // 非必须,推送条件设置
PushMessage *PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
RequestId string `json:"request_id"` // 必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Audience string `json:"audience"` // 必须字段,必须为all
Settings *publics.Settings `json:"settings"` // 非必须,推送条件设置
PushMessage *publics.PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *publics.PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
}

// 群推返回
type PushAllResult struct {
PublicResult
publics.PublicResult
Data map[string]string `json:"data"`
}

// 群推
func PushAll(ctx context.Context, config GeTuiConfig, token string, param *PushAllParam) (*PushAllResult, error) {
func PushAll(ctx context.Context, config publics.GeTuiConfig, token string, param *PushAllParam) (*PushAllResult, error) {

url := ApiUrl + config.AppId + "/push/all"
url := publics.ApiUrl + config.AppId + "/push/all"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions push/all/push_fast_custom_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ package all
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 使用标签快速推送参数
type PushFastCustomTagParam struct {
RequestId string `json:"request_id"` // 必须字段,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
Settings *Settings `json:"settings"` // 非必须,推送条件设置
Audience *Audience `json:"audience"` // 必须字段,tag数组
PushMessage *PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
RequestId string `json:"request_id"` // 必须字段,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
Settings *publics.Settings `json:"settings"` // 非必须,推送条件设置
Audience *publics.Audience `json:"audience"` // 必须字段,tag数组
PushMessage *publics.PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *publics.PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
}

// 使用标签快速推送返回
type PushFastCustomTagResult struct {
PublicResult
publics.PublicResult
Data map[string]map[string]string `json:"data"`
}

// 根据条件筛选用户推送
func PushFastCustomTag(ctx context.Context, config GeTuiConfig, token string, param *PushFastCustomTagParam) (*PushFastCustomTagResult, error) {
url := ApiUrl + config.AppId + "/push/fast_custom_tag"
func PushFastCustomTag(ctx context.Context, config publics.GeTuiConfig, token string, param *PushFastCustomTagParam) (*PushFastCustomTagResult, error) {
url := publics.ApiUrl + config.AppId + "/push/fast_custom_tag"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions push/all/push_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ package all
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 根据条件筛选用户推送参数
type PushTagParam struct {
RequestId string `json:"request_id"` // 必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Settings *Settings `json:"settings"` // 非必须,推送条件设置
Audience *Audience `json:"audience"` // 必须字段,tag数组
PushMessage *PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
RequestId string `json:"request_id"` // 必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Settings *publics.Settings `json:"settings"` // 非必须,推送条件设置
Audience *publics.Audience `json:"audience"` // 必须字段,tag数组
PushMessage *publics.PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *publics.PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
}

// 根据条件筛选用户推送返回
type PushTagParamResult struct {
PublicResult
publics.PublicResult
Data map[string]string `json:"data"`
}

// 根据条件筛选用户推送
func PushTag(ctx context.Context, config GeTuiConfig, token string, param *PushTagParam) (*PushTagParamResult, error) {
url := ApiUrl + config.AppId + "/push/tag"
func PushTag(ctx context.Context, config publics.GeTuiConfig, token string, param *PushTagParam) (*PushTagParamResult, error) {
url := publics.ApiUrl + config.AppId + "/push/tag"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions push/list/push_list_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ package list
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 别名批量推参数
type PushListAliasParam struct {
Audience *Audience `json:"audience"` // 必须字段,用alias数组,,注意这里 !!数组长度不大于200
IsAsync bool `json:"is_async"` // 非必须,默认值:false,是否异步推送,异步推送不会返回data,is_async为false时返回data
TaskId string `json:"taskid"` // 必须字段,默认值:无,使用创建消息接口返回的taskId,可以多次使用
Audience *publics.Audience `json:"audience"` // 必须字段,用alias数组,,注意这里 !!数组长度不大于200
IsAsync bool `json:"is_async"` // 非必须,默认值:false,是否异步推送,异步推送不会返回data,is_async为false时返回data
TaskId string `json:"taskid"` // 必须字段,默认值:无,使用创建消息接口返回的taskId,可以多次使用
}

// 别名批量推返回
type PushListAliasResult struct {
PublicResult
publics.PublicResult
Data map[string]map[string]string `json:"data"`
}

// 别名批量推
func PushListAlias(ctx context.Context, config GeTuiConfig, token string, param *PushListAliasParam) (*PushListAliasResult, error) {
func PushListAlias(ctx context.Context, config publics.GeTuiConfig, token string, param *PushListAliasParam) (*PushListAliasResult, error) {

url := ApiUrl + config.AppId + "/push/list/alias"
url := publics.ApiUrl + config.AppId + "/push/list/alias"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions push/list/push_list_cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ package list
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// cid批量推参数
type PushListCidParam struct {
Audience *Audience `json:"audience"` // 必须字段,用cid数组,多个cid,注意这里 !!数组长度不大于200
IsAsync bool `json:"is_async"` // 非必须,默认值:false,是否异步推送,异步推送不会返回data,is_async为false时返回data
TaskId string `json:"taskid"` // 必须字段,默认值:无,使用创建消息接口返回的taskId,可以多次使用
Audience *publics.Audience `json:"audience"` // 必须字段,用cid数组,多个cid,注意这里 !!数组长度不大于200
IsAsync bool `json:"is_async"` // 非必须,默认值:false,是否异步推送,异步推送不会返回data,is_async为false时返回data
TaskId string `json:"taskid"` // 必须字段,默认值:无,使用创建消息接口返回的taskId,可以多次使用

}

// cid批量推返回
type PushListCidResult struct {
PublicResult
publics.PublicResult
Data map[string]map[string]string `json:"data"`
}

// cid批量推
func PushListCid(ctx context.Context, config GeTuiConfig, token string, param *PushListCidParam) (*PushListCidResult, error) {
func PushListCid(ctx context.Context, config publics.GeTuiConfig, token string, param *PushListCidParam) (*PushListCidResult, error) {

url := ApiUrl + config.AppId + "/push/list/cid"
url := publics.ApiUrl + config.AppId + "/push/list/cid"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions push/list/push_list_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ package list
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 创建消息体参数
type PushListMessageParam struct {
RequestId string `json:"request_id"` // 非必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Settings *Settings `json:"settings"` // 非必须,推送条件设置
PushMessage *PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
RequestId string `json:"request_id"` // 非必须,请求唯一标识号,10-32位之间;如果request_id重复,会导致消息丢失
GroupName string `json:"group_name"` // 非必须,任务组名
Settings *publics.Settings `json:"settings"` // 非必须,推送条件设置
PushMessage *publics.PushMessage `json:"push_message"` // 必须字段,个推推送消息参数
PushChannel *publics.PushChannel `json:"push_channel"` // 非必须,厂商推送消息参数,包含ios消息参数,android厂商消息参数
}

// 创建消息体返回
type PushListMessageResult struct {
PublicResult
publics.PublicResult
Data map[string]string `json:"data"` // taskid:任务编号,用于执行cid批量推和执行别名批量推,此taskid可以多次使用,有效期为用户设置的离线时间
}

// 创建消息体
func PushListMessage(ctx context.Context, config GeTuiConfig, token string, param *PushListMessageParam) (*PushListMessageResult, error) {
func PushListMessage(ctx context.Context, config publics.GeTuiConfig, token string, param *PushListMessageParam) (*PushListMessageResult, error) {

url := ApiUrl + config.AppId + "/push/list/message"
url := publics.ApiUrl + config.AppId + "/push/list/message"
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "POST", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "POST", token)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions push/mission/push_del_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package mission
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 删除定时任务参数
Expand All @@ -14,18 +14,18 @@ type PushDelTaskParam struct {

// 删除定时任务返回
type PushDelTaskResult struct {
PublicResult
publics.PublicResult
}

// 删除定时任务
func PushDelTask(ctx context.Context, config GeTuiConfig, token string, param *PushDelTaskParam) (*PushDelTaskResult, error) {
url := ApiUrl + config.AppId + "/task/schedule" + param.TaskId
func PushDelTask(ctx context.Context, config publics.GeTuiConfig, token string, param *PushDelTaskParam) (*PushDelTaskResult, error) {
url := publics.ApiUrl + config.AppId + "/task/schedule" + param.TaskId
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "DELETE", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "DELETE", token)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions push/mission/push_get_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package mission
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 查询定时任务参数
Expand All @@ -14,7 +14,7 @@ type PushGetTaskParam struct {

// 查询定时任务返回
type PushGetTaskResult struct {
PublicResult
publics.PublicResult
Data map[string]map[string]string `json:"data"`
}

Expand All @@ -29,14 +29,14 @@ type PushGetTaskResult struct {
// }

// 停止任务
func PushGetTask(ctx context.Context, config GeTuiConfig, token string, param *PushGetTaskParam) (*PushGetTaskResult, error) {
url := ApiUrl + config.AppId + "/task/schedule" + param.TaskId
func PushGetTask(ctx context.Context, config publics.GeTuiConfig, token string, param *PushGetTaskParam) (*PushGetTaskResult, error) {
url := publics.ApiUrl + config.AppId + "/task/schedule" + param.TaskId
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "GET", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "GET", token)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions push/mission/push_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package mission
import (
"context"
"encoding/json"
. "getui/publics"
"github.com/dacker-soul/getui/publics"
)

// 停止任务参数
Expand All @@ -14,18 +14,18 @@ type PushStopParam struct {

// 停止任务返回
type PushStopResult struct {
PublicResult
publics.PublicResult
}

// 停止任务
func PushStop(ctx context.Context, config GeTuiConfig, token string, param *PushStopParam) (*PushStopResult, error) {
url := ApiUrl + config.AppId + "/task/" + param.TaskId
func PushStop(ctx context.Context, config publics.GeTuiConfig, token string, param *PushStopParam) (*PushStopResult, error) {
url := publics.ApiUrl + config.AppId + "/task/" + param.TaskId
bodyByte, err := json.Marshal(param)
if err != nil {
return nil, err
}

result, err := RestFulRequest(ctx, bodyByte, url, "DELETE", token)
result, err := publics.RestFulRequest(ctx, bodyByte, url, "DELETE", token)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 1d1affb

Please sign in to comment.