Supported query push records.

This commit is contained in:
sdk-team
2019-10-25 15:35:50 +08:00
parent 5a9569e804
commit c5ef4b1c88
9 changed files with 424 additions and 4 deletions

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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "cps");
}
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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "cps");
}
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, "");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "cps");
}
PushClient::~PushClient()
@@ -879,6 +879,42 @@ PushClient::QueryPushListOutcomeCallable PushClient::queryPushListCallable(const
return task->get_future();
}
PushClient::QueryPushRecordsOutcome PushClient::queryPushRecords(const QueryPushRecordsRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return QueryPushRecordsOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return QueryPushRecordsOutcome(QueryPushRecordsResult(outcome.result()));
else
return QueryPushRecordsOutcome(outcome.error());
}
void PushClient::queryPushRecordsAsync(const QueryPushRecordsRequest& request, const QueryPushRecordsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, queryPushRecords(request), context);
};
asyncExecute(new Runnable(fn));
}
PushClient::QueryPushRecordsOutcomeCallable PushClient::queryPushRecordsCallable(const QueryPushRecordsRequest &request) const
{
auto task = std::make_shared<std::packaged_task<QueryPushRecordsOutcome()>>(
[this, request]()
{
return this->queryPushRecords(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
PushClient::QueryPushStatByAppOutcome PushClient::queryPushStatByApp(const QueryPushStatByAppRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,137 @@
/*
* 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/QueryPushRecordsRequest.h>
using AlibabaCloud::Push::Model::QueryPushRecordsRequest;
QueryPushRecordsRequest::QueryPushRecordsRequest() :
RpcServiceRequest("push", "2016-08-01", "QueryPushRecords")
{}
QueryPushRecordsRequest::~QueryPushRecordsRequest()
{}
std::string QueryPushRecordsRequest::getStartTime()const
{
return startTime_;
}
void QueryPushRecordsRequest::setStartTime(const std::string& startTime)
{
startTime_ = startTime;
setCoreParameter("StartTime", startTime);
}
std::string QueryPushRecordsRequest::getSource()const
{
return source_;
}
void QueryPushRecordsRequest::setSource(const std::string& source)
{
source_ = source;
setCoreParameter("Source", source);
}
std::string QueryPushRecordsRequest::getAccessKeyId()const
{
return accessKeyId_;
}
void QueryPushRecordsRequest::setAccessKeyId(const std::string& accessKeyId)
{
accessKeyId_ = accessKeyId;
setCoreParameter("AccessKeyId", accessKeyId);
}
std::string QueryPushRecordsRequest::getNextToken()const
{
return nextToken_;
}
void QueryPushRecordsRequest::setNextToken(const std::string& nextToken)
{
nextToken_ = nextToken;
setCoreParameter("NextToken", nextToken);
}
int QueryPushRecordsRequest::getPageSize()const
{
return pageSize_;
}
void QueryPushRecordsRequest::setPageSize(int pageSize)
{
pageSize_ = pageSize;
setCoreParameter("PageSize", std::to_string(pageSize));
}
std::string QueryPushRecordsRequest::getKeyword()const
{
return keyword_;
}
void QueryPushRecordsRequest::setKeyword(const std::string& keyword)
{
keyword_ = keyword;
setCoreParameter("Keyword", keyword);
}
std::string QueryPushRecordsRequest::getEndTime()const
{
return endTime_;
}
void QueryPushRecordsRequest::setEndTime(const std::string& endTime)
{
endTime_ = endTime;
setCoreParameter("EndTime", endTime);
}
std::string QueryPushRecordsRequest::getTarget()const
{
return target_;
}
void QueryPushRecordsRequest::setTarget(const std::string& target)
{
target_ = target;
setCoreParameter("Target", target);
}
long QueryPushRecordsRequest::getAppKey()const
{
return appKey_;
}
void QueryPushRecordsRequest::setAppKey(long appKey)
{
appKey_ = appKey;
setCoreParameter("AppKey", std::to_string(appKey));
}
std::string QueryPushRecordsRequest::getPushType()const
{
return pushType_;
}
void QueryPushRecordsRequest::setPushType(const std::string& pushType)
{
pushType_ = pushType;
setCoreParameter("PushType", pushType);
}

View File

@@ -0,0 +1,89 @@
/*
* 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/QueryPushRecordsResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Push;
using namespace AlibabaCloud::Push::Model;
QueryPushRecordsResult::QueryPushRecordsResult() :
ServiceResult()
{}
QueryPushRecordsResult::QueryPushRecordsResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
QueryPushRecordsResult::~QueryPushRecordsResult()
{}
void QueryPushRecordsResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto allPushInfosNode = value["PushInfos"]["PushInfo"];
for (auto valuePushInfosPushInfo : allPushInfosNode)
{
PushInfo pushInfosObject;
if(!valuePushInfosPushInfo["AppKey"].isNull())
pushInfosObject.appKey = std::stol(valuePushInfosPushInfo["AppKey"].asString());
if(!valuePushInfosPushInfo["MessageId"].isNull())
pushInfosObject.messageId = std::stol(valuePushInfosPushInfo["MessageId"].asString());
if(!valuePushInfosPushInfo["PushType"].isNull())
pushInfosObject.pushType = valuePushInfosPushInfo["PushType"].asString();
if(!valuePushInfosPushInfo["DeviceType"].isNull())
pushInfosObject.deviceType = valuePushInfosPushInfo["DeviceType"].asString();
if(!valuePushInfosPushInfo["Target"].isNull())
pushInfosObject.target = valuePushInfosPushInfo["Target"].asString();
if(!valuePushInfosPushInfo["Source"].isNull())
pushInfosObject.source = valuePushInfosPushInfo["Source"].asString();
if(!valuePushInfosPushInfo["PushTime"].isNull())
pushInfosObject.pushTime = valuePushInfosPushInfo["PushTime"].asString();
if(!valuePushInfosPushInfo["Title"].isNull())
pushInfosObject.title = valuePushInfosPushInfo["Title"].asString();
if(!valuePushInfosPushInfo["Body"].isNull())
pushInfosObject.body = valuePushInfosPushInfo["Body"].asString();
if(!valuePushInfosPushInfo["Status"].isNull())
pushInfosObject.status = valuePushInfosPushInfo["Status"].asString();
pushInfos_.push_back(pushInfosObject);
}
if(!value["NextToken"].isNull())
nextToken_ = value["NextToken"].asString();
if(!value["PageSize"].isNull())
pageSize_ = std::stoi(value["PageSize"].asString());
}
std::vector<QueryPushRecordsResult::PushInfo> QueryPushRecordsResult::getPushInfos()const
{
return pushInfos_;
}
std::string QueryPushRecordsResult::getNextToken()const
{
return nextToken_;
}
int QueryPushRecordsResult::getPageSize()const
{
return pageSize_;
}