package client import ( "io/ioutil" "k8s.io/apimachinery/pkg/util/json" "log" "net/http" "strings" "sync" ) type notice struct { sync.RWMutex client *client options *NoticeOptions log log.Logger } func newNotice(client *client, options *NoticeOptions) (*notice, error) { notice := ¬ice{ RWMutex: sync.RWMutex{}, client: client, options: options, log: log.Logger{}, } return notice, nil } func (n *notice) PushNotice(pushNoticeReq PushNoticeReq) (*PushNoticeResp, error) { url := n.client.url + "/pcm/v1/core/pushNotice" method := "GET" jsonStr, _ := json.Marshal(pushNoticeReq) payload := strings.NewReader(string(jsonStr)) client := &http.Client{} req, _ := http.NewRequest(method, url, payload) req.Header.Add("Content-Type", "application/json") res, _ := client.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) var resp PushNoticeResp json.Unmarshal(body, &resp) return &resp, nil }