httplib_mmm_open_api_service_gateway.go 1.2 KB
package service_gateway

import (
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
	"strings"
	"time"
)

type HttplibMmmOpenApiServiceGateway struct {
	httplibBaseServiceGateway
}

func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error) {
	url := strings.Join([]string{serviceGateway.baseURL, "v1", "push", "pushInfo"}, "/")
	request := serviceGateway.createRequest(url, "post")
	options := make(map[string]interface{})
	options["mmmType"] = msgType
	options["project"] = "worth"
	options["receivers"] = uids
	options["title"] = title
	options["content"] = content
	options["ext"] = ext
	request.JSONBody(options)
	response := make(map[string]interface{})
	request.ToJSON(&response)
	data, err := serviceGateway.responseHandle(response)
	return data, err
}

func NewHttplibMmmOpenApiServiceGateway() *HttplibMmmOpenApiServiceGateway {
	return &HttplibMmmOpenApiServiceGateway{
		httplibBaseServiceGateway: httplibBaseServiceGateway{
			baseURL:          constant.MMM_OPEN_API_SERVICE_HOST,
			connectTimeout:   100 * time.Second,
			readWriteTimeout: 30 * time.Second,
		},
	}
}