ソースを参照

Merge pull request #248 from wenzuochao/dev_4.1.1

fix some of param of push api can not be incomed
wenzuochao 6 年 前
コミット
c18169111d
2 ファイル変更39 行追加16 行削除
  1. 28 5
      services/push/client.go
  2. 11 11
      services/push/push.go

+ 28 - 5
services/push/client.go

@@ -18,6 +18,7 @@ package push
 import (
 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
 )
 
 // Client is the sdk client struct, each func corresponds to an OpenAPI
@@ -32,6 +33,20 @@ func NewClient() (client *Client, err error) {
 	return
 }
 
+// NewClientWithProvider creates a sdk client with providers
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) {
+	client = &Client{}
+	var pc provider.Provider
+	if len(providers) == 0 {
+		pc = provider.DefaultChain
+	} else {
+		pc = provider.NewProviderChain(providers)
+	}
+	err = client.InitWithProviderChain(regionId, pc)
+	return
+}
+
 // NewClientWithOptions creates a sdk client with regionId/sdkConfig/credential
 // this is the common api to create a sdk client
 func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
@@ -41,7 +56,7 @@ func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.C
 }
 
 // NewClientWithAccessKey is a shortcut to create sdk client with accesskey
-// usage: https://help.aliyun.com/document_detail/66217.html
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
 func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
@@ -49,7 +64,7 @@ func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (clie
 }
 
 // NewClientWithStsToken is a shortcut to create sdk client with sts token
-// usage: https://help.aliyun.com/document_detail/66222.html
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
 func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
@@ -57,15 +72,23 @@ func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToke
 }
 
 // NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn
-// usage: https://help.aliyun.com/document_detail/66222.html
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
 func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
 	return
 }
 
+// NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn and policy
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
+func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
+	client = &Client{}
+	err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
+	return
+}
+
 // NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role
-// usage: https://help.aliyun.com/document_detail/66223.html
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
 func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithEcsRamRole(regionId, roleName)
@@ -73,7 +96,7 @@ func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client,
 }
 
 // NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair
-// attention: rsa key pair auth is only Japan regions available
+// usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
 func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
 	client = &Client{}
 	err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)

+ 11 - 11
services/push/push.go

@@ -89,17 +89,17 @@ type PushRequest struct {
 	StoreOffline                   requests.Boolean `position:"Query" name:"StoreOffline"`
 	PushTime                       string           `position:"Query" name:"PushTime"`
 	ExpireTime                     string           `position:"Query" name:"ExpireTime"`
-	iOSApnsEnv                     string           `position:"Query" name:"iOSApnsEnv"`
-	iOSRemind                      requests.Boolean `position:"Query" name:"iOSRemind"`
-	iOSRemindBody                  string           `position:"Query" name:"iOSRemindBody"`
-	iOSBadge                       requests.Integer `position:"Query" name:"iOSBadge"`
-	iOSBadgeAutoIncrement          requests.Boolean `position:"Query" name:"iOSBadgeAutoIncrement"`
-	iOSSilentNotification          requests.Boolean `position:"Query" name:"iOSSilentNotification"`
-	iOSMusic                       string           `position:"Query" name:"iOSMusic"`
-	iOSSubtitle                    string           `position:"Query" name:"iOSSubtitle"`
-	iOSNotificationCategory        string           `position:"Query" name:"iOSNotificationCategory"`
-	iOSMutableContent              requests.Boolean `position:"Query" name:"iOSMutableContent"`
-	iOSExtParameters               string           `position:"Query" name:"iOSExtParameters"`
+	IOSApnsEnv                     string           `position:"Query" name:"IOSApnsEnv"`
+	IOSRemind                      requests.Boolean `position:"Query" name:"IOSRemind"`
+	IOSRemindBody                  string           `position:"Query" name:"IOSRemindBody"`
+	IOSBadge                       requests.Integer `position:"Query" name:"IOSBadge"`
+	IOSBadgeAutoIncrement          requests.Boolean `position:"Query" name:"IOSBadgeAutoIncrement"`
+	IOSSilentNotification          requests.Boolean `position:"Query" name:"IOSSilentNotification"`
+	IOSMusic                       string           `position:"Query" name:"IOSMusic"`
+	IOSSubtitle                    string           `position:"Query" name:"IOSSubtitle"`
+	IOSNotificationCategory        string           `position:"Query" name:"IOSNotificationCategory"`
+	IOSMutableContent              requests.Boolean `position:"Query" name:"IOSMutableContent"`
+	IOSExtParameters               string           `position:"Query" name:"IOSExtParameters"`
 	AndroidNotifyType              string           `position:"Query" name:"AndroidNotifyType"`
 	AndroidOpenType                string           `position:"Query" name:"AndroidOpenType"`
 	AndroidActivity                string           `position:"Query" name:"AndroidActivity"`