diff --git a/CHANGELOG b/CHANGELOG index b035c1ec4..99831d2b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2019-10-08 Version 1.36.145 +- Supported API MassPush for Push Message or Notice. + 2019-10-08 Version 1.36.144 - Generated 2016-01-20 for `Kms`. diff --git a/VERSION b/VERSION index c34b79d65..356f08520 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.144 \ No newline at end of file +1.36.145 \ No newline at end of file diff --git a/push/CMakeLists.txt b/push/CMakeLists.txt index 64e019dc9..41065038b 100644 --- a/push/CMakeLists.txt +++ b/push/CMakeLists.txt @@ -39,6 +39,8 @@ set(push_public_header_model include/alibabacloud/push/model/ListSummaryAppsResult.h include/alibabacloud/push/model/ListTagsRequest.h include/alibabacloud/push/model/ListTagsResult.h + include/alibabacloud/push/model/MassPushRequest.h + include/alibabacloud/push/model/MassPushResult.h include/alibabacloud/push/model/PushRequest.h include/alibabacloud/push/model/PushResult.h include/alibabacloud/push/model/PushMessageToAndroidRequest.h @@ -98,6 +100,8 @@ set(push_src src/model/ListSummaryAppsResult.cc src/model/ListTagsRequest.cc src/model/ListTagsResult.cc + src/model/MassPushRequest.cc + src/model/MassPushResult.cc src/model/PushRequest.cc src/model/PushResult.cc src/model/PushMessageToAndroidRequest.cc diff --git a/push/include/alibabacloud/push/PushClient.h b/push/include/alibabacloud/push/PushClient.h index 810d7d491..76bb89947 100644 --- a/push/include/alibabacloud/push/PushClient.h +++ b/push/include/alibabacloud/push/PushClient.h @@ -40,6 +40,8 @@ #include "model/ListSummaryAppsResult.h" #include "model/ListTagsRequest.h" #include "model/ListTagsResult.h" +#include "model/MassPushRequest.h" +#include "model/MassPushResult.h" #include "model/PushRequest.h" #include "model/PushResult.h" #include "model/PushMessageToAndroidRequest.h" @@ -114,6 +116,9 @@ namespace AlibabaCloud typedef Outcome ListTagsOutcome; typedef std::future ListTagsOutcomeCallable; typedef std::function&)> ListTagsAsyncHandler; + typedef Outcome MassPushOutcome; + typedef std::future MassPushOutcomeCallable; + typedef std::function&)> MassPushAsyncHandler; typedef Outcome PushOutcome; typedef std::future PushOutcomeCallable; typedef std::function&)> PushAsyncHandler; @@ -203,6 +208,9 @@ namespace AlibabaCloud ListTagsOutcome listTags(const Model::ListTagsRequest &request)const; void listTagsAsync(const Model::ListTagsRequest& request, const ListTagsAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; ListTagsOutcomeCallable listTagsCallable(const Model::ListTagsRequest& request) const; + MassPushOutcome massPush(const Model::MassPushRequest &request)const; + void massPushAsync(const Model::MassPushRequest& request, const MassPushAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + MassPushOutcomeCallable massPushCallable(const Model::MassPushRequest& request) const; PushOutcome push(const Model::PushRequest &request)const; void pushAsync(const Model::PushRequest& request, const PushAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; PushOutcomeCallable pushCallable(const Model::PushRequest& request) const; diff --git a/push/include/alibabacloud/push/model/MassPushRequest.h b/push/include/alibabacloud/push/model/MassPushRequest.h new file mode 100644 index 000000000..e37af178b --- /dev/null +++ b/push/include/alibabacloud/push/model/MassPushRequest.h @@ -0,0 +1,95 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_PUSH_MODEL_MASSPUSHREQUEST_H_ +#define ALIBABACLOUD_PUSH_MODEL_MASSPUSHREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Push + { + namespace Model + { + class ALIBABACLOUD_PUSH_EXPORT MassPushRequest : public RpcServiceRequest + { + struct PushTask + { + int androidNotificationBarType; + std::string androidExtParameters; + int iOSBadge; + bool iOSBadgeAutoIncrement; + std::string androidOpenType; + std::string title; + std::string body; + std::string deviceType; + std::string pushTime; + int sendSpeed; + std::string androidPopupActivity; + std::string iOSRemindBody; + std::string iOSExtParameters; + std::string androidNotifyType; + std::string androidPopupTitle; + std::string iOSMusic; + std::string iOSApnsEnv; + bool iOSMutableContent; + int androidNotificationBarPriority; + std::string expireTime; + std::string androidPopupBody; + std::string iOSNotificationCategory; + bool storeOffline; + bool iOSSilentNotification; + std::string jobKey; + std::string target; + std::string androidOpenUrl; + std::string androidNotificationChannel; + bool androidRemind; + std::string androidActivity; + std::string androidXiaoMiNotifyBody; + std::string iOSSubtitle; + bool iOSRemind; + std::string targetValue; + std::string androidMusic; + std::string androidXiaoMiActivity; + std::string androidXiaoMiNotifyTitle; + std::string pushType; + }; + + public: + MassPushRequest(); + ~MassPushRequest(); + + std::string getAccessKeyId()const; + void setAccessKeyId(const std::string& accessKeyId); + std::vector getPushTask()const; + void setPushTask(const std::vector& pushTask); + long getAppKey()const; + void setAppKey(long appKey); + + private: + std::string accessKeyId_; + std::vector pushTask_; + long appKey_; + + }; + } + } +} +#endif // !ALIBABACLOUD_PUSH_MODEL_MASSPUSHREQUEST_H_ \ No newline at end of file diff --git a/push/include/alibabacloud/push/model/MassPushResult.h b/push/include/alibabacloud/push/model/MassPushResult.h new file mode 100644 index 000000000..f2cbb86c1 --- /dev/null +++ b/push/include/alibabacloud/push/model/MassPushResult.h @@ -0,0 +1,51 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ALIBABACLOUD_PUSH_MODEL_MASSPUSHRESULT_H_ +#define ALIBABACLOUD_PUSH_MODEL_MASSPUSHRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Push + { + namespace Model + { + class ALIBABACLOUD_PUSH_EXPORT MassPushResult : public ServiceResult + { + public: + + + MassPushResult(); + explicit MassPushResult(const std::string &payload); + ~MassPushResult(); + std::vector getMessageIds()const; + + protected: + void parse(const std::string &payload); + private: + std::vector messageIds_; + + }; + } + } +} +#endif // !ALIBABACLOUD_PUSH_MODEL_MASSPUSHRESULT_H_ \ No newline at end of file diff --git a/push/src/PushClient.cc b/push/src/PushClient.cc index 265c33a6a..4772eff47 100644 --- a/push/src/PushClient.cc +++ b/push/src/PushClient.cc @@ -31,21 +31,21 @@ PushClient::PushClient(const Credentials &credentials, const ClientConfiguration RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) { auto locationClient = std::make_shared(credentials, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "push"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } PushClient::PushClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) { auto locationClient = std::make_shared(credentialsProvider, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "push"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } PushClient::PushClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) : RpcServiceClient(SERVICE_NAME, std::make_shared(accessKeyId, accessKeySecret), configuration) { auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); - endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "push"); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, ""); } PushClient::~PushClient() @@ -375,6 +375,42 @@ PushClient::ListTagsOutcomeCallable PushClient::listTagsCallable(const ListTagsR return task->get_future(); } +PushClient::MassPushOutcome PushClient::massPush(const MassPushRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return MassPushOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return MassPushOutcome(MassPushResult(outcome.result())); + else + return MassPushOutcome(outcome.error()); +} + +void PushClient::massPushAsync(const MassPushRequest& request, const MassPushAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, massPush(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +PushClient::MassPushOutcomeCallable PushClient::massPushCallable(const MassPushRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->massPush(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + PushClient::PushOutcome PushClient::push(const PushRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/push/src/model/MassPushRequest.cc b/push/src/model/MassPushRequest.cc new file mode 100644 index 000000000..e7d4ede8c --- /dev/null +++ b/push/src/model/MassPushRequest.cc @@ -0,0 +1,102 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +using AlibabaCloud::Push::Model::MassPushRequest; + +MassPushRequest::MassPushRequest() : + RpcServiceRequest("push", "2016-08-01", "MassPush") +{} + +MassPushRequest::~MassPushRequest() +{} + +std::string MassPushRequest::getAccessKeyId()const +{ + return accessKeyId_; +} + +void MassPushRequest::setAccessKeyId(const std::string& accessKeyId) +{ + accessKeyId_ = accessKeyId; + setCoreParameter("AccessKeyId", accessKeyId); +} + +std::vector MassPushRequest::getPushTask()const +{ + return pushTask_; +} + +void MassPushRequest::setPushTask(const std::vector& pushTask) +{ + pushTask_ = pushTask; + int i = 0; + for(int i = 0; i!= pushTask.size(); i++) { + auto obj = pushTask.at(i); + std::string str ="PushTask."+ std::to_string(i); + setCoreParameter(str + ".AndroidNotificationBarType", std::to_string(obj.androidNotificationBarType)); + setCoreParameter(str + ".AndroidExtParameters", obj.androidExtParameters); + setCoreParameter(str + ".iOSBadge", std::to_string(obj.iOSBadge)); + setCoreParameter(str + ".iOSBadgeAutoIncrement", obj.iOSBadgeAutoIncrement ? "true" : "false"); + setCoreParameter(str + ".AndroidOpenType", obj.androidOpenType); + setCoreParameter(str + ".Title", obj.title); + setCoreParameter(str + ".Body", obj.body); + setCoreParameter(str + ".DeviceType", obj.deviceType); + setCoreParameter(str + ".PushTime", obj.pushTime); + setCoreParameter(str + ".SendSpeed", std::to_string(obj.sendSpeed)); + setCoreParameter(str + ".AndroidPopupActivity", obj.androidPopupActivity); + setCoreParameter(str + ".iOSRemindBody", obj.iOSRemindBody); + setCoreParameter(str + ".iOSExtParameters", obj.iOSExtParameters); + setCoreParameter(str + ".AndroidNotifyType", obj.androidNotifyType); + setCoreParameter(str + ".AndroidPopupTitle", obj.androidPopupTitle); + setCoreParameter(str + ".iOSMusic", obj.iOSMusic); + setCoreParameter(str + ".iOSApnsEnv", obj.iOSApnsEnv); + setCoreParameter(str + ".iOSMutableContent", obj.iOSMutableContent ? "true" : "false"); + setCoreParameter(str + ".AndroidNotificationBarPriority", std::to_string(obj.androidNotificationBarPriority)); + setCoreParameter(str + ".ExpireTime", obj.expireTime); + setCoreParameter(str + ".AndroidPopupBody", obj.androidPopupBody); + setCoreParameter(str + ".iOSNotificationCategory", obj.iOSNotificationCategory); + setCoreParameter(str + ".StoreOffline", obj.storeOffline ? "true" : "false"); + setCoreParameter(str + ".iOSSilentNotification", obj.iOSSilentNotification ? "true" : "false"); + setCoreParameter(str + ".JobKey", obj.jobKey); + setCoreParameter(str + ".Target", obj.target); + setCoreParameter(str + ".AndroidOpenUrl", obj.androidOpenUrl); + setCoreParameter(str + ".AndroidNotificationChannel", obj.androidNotificationChannel); + setCoreParameter(str + ".AndroidRemind", obj.androidRemind ? "true" : "false"); + setCoreParameter(str + ".AndroidActivity", obj.androidActivity); + setCoreParameter(str + ".AndroidXiaoMiNotifyBody", obj.androidXiaoMiNotifyBody); + setCoreParameter(str + ".iOSSubtitle", obj.iOSSubtitle); + setCoreParameter(str + ".iOSRemind", obj.iOSRemind ? "true" : "false"); + setCoreParameter(str + ".TargetValue", obj.targetValue); + setCoreParameter(str + ".AndroidMusic", obj.androidMusic); + setCoreParameter(str + ".AndroidXiaoMiActivity", obj.androidXiaoMiActivity); + setCoreParameter(str + ".AndroidXiaoMiNotifyTitle", obj.androidXiaoMiNotifyTitle); + setCoreParameter(str + ".PushType", obj.pushType); + } +} + +long MassPushRequest::getAppKey()const +{ + return appKey_; +} + +void MassPushRequest::setAppKey(long appKey) +{ + appKey_ = appKey; + setCoreParameter("AppKey", std::to_string(appKey)); +} + diff --git a/push/src/model/MassPushResult.cc b/push/src/model/MassPushResult.cc new file mode 100644 index 000000000..d2974c27b --- /dev/null +++ b/push/src/model/MassPushResult.cc @@ -0,0 +1,52 @@ +/* + * Copyright 2009-2017 Alibaba Cloud All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace AlibabaCloud::Push; +using namespace AlibabaCloud::Push::Model; + +MassPushResult::MassPushResult() : + ServiceResult() +{} + +MassPushResult::MassPushResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +MassPushResult::~MassPushResult() +{} + +void MassPushResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto allMessageIds = value["MessageIds"]["MessageId"]; + for (const auto &item : allMessageIds) + messageIds_.push_back(item.asString()); + +} + +std::vector MassPushResult::getMessageIds()const +{ + return messageIds_; +} +