蛋蛋星球-制度模式
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

client_schedule.go 1.4 KiB

pirms 4 nedēļām
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package jpush
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "strconv"
  6. )
  7. func (c *Client) ScheduleCreateTask(req *ScheduleRequest) (map[string]interface{}, error) {
  8. link := c.pushUrl + "/v3/schedules"
  9. buf, err := json.Marshal(req)
  10. if err != nil {
  11. return nil, err
  12. }
  13. resp, err := c.request("POST", link, bytes.NewReader(buf), false)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return resp.Map()
  18. }
  19. func (c *Client) ScheduleGetList(page int) (map[string]interface{}, error) {
  20. link := c.pushUrl + "/v3/schedules"
  21. if page > 0 {
  22. link += "?page=" + strconv.Itoa(page)
  23. }
  24. resp, err := c.request("GET", link, nil, false)
  25. if err != nil {
  26. return nil, err
  27. }
  28. return resp.Map()
  29. }
  30. func (c *Client) ScheduleView(id string) (map[string]interface{}, error) {
  31. link := c.pushUrl + "/v3/schedules/" + id
  32. resp, err := c.request("GET", link, nil, false)
  33. if err != nil {
  34. return nil, err
  35. }
  36. return resp.Map()
  37. }
  38. func (c *Client) ScheduleUpdate(id string, req *ScheduleRequest) (map[string]interface{}, error) {
  39. link := c.pushUrl + "/v3/schedules/" + id
  40. buf, err := json.Marshal(req)
  41. if err != nil {
  42. return nil, err
  43. }
  44. resp, err := c.request("PUT", link, bytes.NewReader(buf), false)
  45. if err != nil {
  46. return nil, err
  47. }
  48. return resp.Map()
  49. }
  50. func (c *Client) ScheduleDelete(id string) ([]byte, error) {
  51. link := c.pushUrl + "/v3/schedules/" + id
  52. resp, err := c.request("DELETE", link, nil, false)
  53. if err != nil {
  54. return nil, err
  55. }
  56. return resp.Bytes(), nil
  57. }