push.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package push
  2. //Licensed under the Apache License, Version 2.0 (the "License");
  3. //you may not use this file except in compliance with the License.
  4. //You may obtain a copy of the License at
  5. //
  6. //http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. //Unless required by applicable law or agreed to in writing, software
  9. //distributed under the License is distributed on an "AS IS" BASIS,
  10. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. //See the License for the specific language governing permissions and
  12. //limitations under the License.
  13. //
  14. // Code generated by Alibaba Cloud SDK Code Generator.
  15. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
  16. import (
  17. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
  19. )
  20. // Push invokes the push.Push API synchronously
  21. // api document: https://help.aliyun.com/api/push/push.html
  22. func (client *Client) Push(request *PushRequest) (response *PushResponse, err error) {
  23. response = CreatePushResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // PushWithChan invokes the push.Push API asynchronously
  28. // api document: https://help.aliyun.com/api/push/push.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) PushWithChan(request *PushRequest) (<-chan *PushResponse, <-chan error) {
  31. responseChan := make(chan *PushResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.Push(request)
  37. if err != nil {
  38. errChan <- err
  39. } else {
  40. responseChan <- response
  41. }
  42. })
  43. if err != nil {
  44. errChan <- err
  45. close(responseChan)
  46. close(errChan)
  47. }
  48. return responseChan, errChan
  49. }
  50. // PushWithCallback invokes the push.Push API asynchronously
  51. // api document: https://help.aliyun.com/api/push/push.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) PushWithCallback(request *PushRequest, callback func(response *PushResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *PushResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.Push(request)
  60. callback(response, err)
  61. result <- 1
  62. })
  63. if err != nil {
  64. defer close(result)
  65. callback(nil, err)
  66. result <- 0
  67. }
  68. return result
  69. }
  70. // PushRequest is the request struct for api Push
  71. type PushRequest struct {
  72. *requests.RpcRequest
  73. AppKey requests.Integer `position:"Query" name:"AppKey"`
  74. PushType string `position:"Query" name:"PushType"`
  75. DeviceType string `position:"Query" name:"DeviceType"`
  76. Target string `position:"Query" name:"Target"`
  77. TargetValue string `position:"Query" name:"TargetValue"`
  78. Title string `position:"Query" name:"Title"`
  79. Body string `position:"Query" name:"Body"`
  80. JobKey string `position:"Query" name:"JobKey"`
  81. SendSpeed requests.Integer `position:"Query" name:"SendSpeed"`
  82. StoreOffline requests.Boolean `position:"Query" name:"StoreOffline"`
  83. PushTime string `position:"Query" name:"PushTime"`
  84. ExpireTime string `position:"Query" name:"ExpireTime"`
  85. IOSApnsEnv string `position:"Query" name:"iOSApnsEnv"`
  86. IOSRemind requests.Boolean `position:"Query" name:"iOSRemind"`
  87. IOSRemindBody string `position:"Query" name:"iOSRemindBody"`
  88. IOSBadge requests.Integer `position:"Query" name:"iOSBadge"`
  89. IOSBadgeAutoIncrement requests.Boolean `position:"Query" name:"iOSBadgeAutoIncrement"`
  90. IOSSilentNotification requests.Boolean `position:"Query" name:"iOSSilentNotification"`
  91. IOSMusic string `position:"Query" name:"iOSMusic"`
  92. IOSSubtitle string `position:"Query" name:"iOSSubtitle"`
  93. IOSNotificationCategory string `position:"Query" name:"iOSNotificationCategory"`
  94. IOSMutableContent requests.Boolean `position:"Query" name:"iOSMutableContent"`
  95. IOSExtParameters string `position:"Query" name:"iOSExtParameters"`
  96. AndroidNotifyType string `position:"Query" name:"AndroidNotifyType"`
  97. AndroidOpenType string `position:"Query" name:"AndroidOpenType"`
  98. AndroidActivity string `position:"Query" name:"AndroidActivity"`
  99. AndroidMusic string `position:"Query" name:"AndroidMusic"`
  100. AndroidOpenUrl string `position:"Query" name:"AndroidOpenUrl"`
  101. AndroidXiaoMiActivity string `position:"Query" name:"AndroidXiaoMiActivity"`
  102. AndroidXiaoMiNotifyTitle string `position:"Query" name:"AndroidXiaoMiNotifyTitle"`
  103. AndroidXiaoMiNotifyBody string `position:"Query" name:"AndroidXiaoMiNotifyBody"`
  104. AndroidPopupActivity string `position:"Query" name:"AndroidPopupActivity"`
  105. AndroidPopupTitle string `position:"Query" name:"AndroidPopupTitle"`
  106. AndroidPopupBody string `position:"Query" name:"AndroidPopupBody"`
  107. AndroidNotificationBarType requests.Integer `position:"Query" name:"AndroidNotificationBarType"`
  108. AndroidNotificationBarPriority requests.Integer `position:"Query" name:"AndroidNotificationBarPriority"`
  109. AndroidExtParameters string `position:"Query" name:"AndroidExtParameters"`
  110. AndroidRemind requests.Boolean `position:"Query" name:"AndroidRemind"`
  111. AndroidNotificationChannel string `position:"Query" name:"AndroidNotificationChannel"`
  112. SmsTemplateName string `position:"Query" name:"SmsTemplateName"`
  113. SmsSignName string `position:"Query" name:"SmsSignName"`
  114. SmsParams string `position:"Query" name:"SmsParams"`
  115. SmsDelaySecs requests.Integer `position:"Query" name:"SmsDelaySecs"`
  116. SmsSendPolicy requests.Integer `position:"Query" name:"SmsSendPolicy"`
  117. }
  118. // PushResponse is the response struct for api Push
  119. type PushResponse struct {
  120. *responses.BaseResponse
  121. RequestId string `json:"RequestId" xml:"RequestId"`
  122. MessageId string `json:"MessageId" xml:"MessageId"`
  123. }
  124. // CreatePushRequest creates a request to invoke Push API
  125. func CreatePushRequest() (request *PushRequest) {
  126. request = &PushRequest{
  127. RpcRequest: &requests.RpcRequest{},
  128. }
  129. request.InitWithApiInfo("Push", "2016-08-01", "Push", "", "")
  130. return
  131. }
  132. // CreatePushResponse creates a response to parse from Push response
  133. func CreatePushResponse() (response *PushResponse) {
  134. response = &PushResponse{
  135. BaseResponse: &responses.BaseResponse{},
  136. }
  137. return
  138. }