Supported API MassPush for Push Message or Notice.

This commit is contained in:
sdk-team
2019-10-08 16:31:12 +08:00
parent 032fbad258
commit 009add7f30
9 changed files with 355 additions and 4 deletions

View File

@@ -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`.

View File

@@ -1 +1 @@
1.36.144
1.36.145

View File

@@ -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

View File

@@ -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<Error, Model::ListTagsResult> ListTagsOutcome;
typedef std::future<ListTagsOutcome> ListTagsOutcomeCallable;
typedef std::function<void(const PushClient*, const Model::ListTagsRequest&, const ListTagsOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ListTagsAsyncHandler;
typedef Outcome<Error, Model::MassPushResult> MassPushOutcome;
typedef std::future<MassPushOutcome> MassPushOutcomeCallable;
typedef std::function<void(const PushClient*, const Model::MassPushRequest&, const MassPushOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> MassPushAsyncHandler;
typedef Outcome<Error, Model::PushResult> PushOutcome;
typedef std::future<PushOutcome> PushOutcomeCallable;
typedef std::function<void(const PushClient*, const Model::PushRequest&, const PushOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& 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<const AsyncCallerContext>& context = nullptr) const;
PushOutcomeCallable pushCallable(const Model::PushRequest& request) const;

View File

@@ -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 <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/push/PushExport.h>
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<PushTask> getPushTask()const;
void setPushTask(const std::vector<PushTask>& pushTask);
long getAppKey()const;
void setAppKey(long appKey);
private:
std::string accessKeyId_;
std::vector<PushTask> pushTask_;
long appKey_;
};
}
}
}
#endif // !ALIBABACLOUD_PUSH_MODEL_MASSPUSHREQUEST_H_

View File

@@ -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 <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/push/PushExport.h>
namespace AlibabaCloud
{
namespace Push
{
namespace Model
{
class ALIBABACLOUD_PUSH_EXPORT MassPushResult : public ServiceResult
{
public:
MassPushResult();
explicit MassPushResult(const std::string &payload);
~MassPushResult();
std::vector<std::string> getMessageIds()const;
protected:
void parse(const std::string &payload);
private:
std::vector<std::string> messageIds_;
};
}
}
}
#endif // !ALIBABACLOUD_PUSH_MODEL_MASSPUSHRESULT_H_

View File

@@ -31,21 +31,21 @@ PushClient::PushClient(const Credentials &credentials, const ClientConfiguration
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "push");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
PushClient::PushClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
{
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "push");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
PushClient::PushClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
{
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "push");
endpointProvider_ = std::make_shared<EndpointProvider>(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<const AsyncCallerContext>& 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<std::packaged_task<MassPushOutcome()>>(
[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();

View File

@@ -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 <alibabacloud/push/model/MassPushRequest.h>
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::PushTask> MassPushRequest::getPushTask()const
{
return pushTask_;
}
void MassPushRequest::setPushTask(const std::vector<PushTask>& 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));
}

View File

@@ -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 <alibabacloud/push/model/MassPushResult.h>
#include <json/json.h>
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<std::string> MassPushResult::getMessageIds()const
{
return messageIds_;
}