Compare commits
10 Commits
Push-patch
...
Metering-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fd70bc2bf | ||
|
|
ee91c28732 | ||
|
|
ec9ecb41d2 | ||
|
|
272e447860 | ||
|
|
3af83f0124 | ||
|
|
2f31a44faf | ||
|
|
512b1bb5c5 | ||
|
|
564c05144a | ||
|
|
8aa1d22f90 | ||
|
|
14ebba9911 |
27
CHANGELOG
27
CHANGELOG
@@ -1,3 +1,30 @@
|
||||
2020-10-19 Version: patch
|
||||
- Metering 1019.
|
||||
|
||||
2020-10-19 Version: patch
|
||||
- Metering 1019.
|
||||
|
||||
2020-10-19 Version: patch
|
||||
- Metering 1019.
|
||||
|
||||
2020-10-17 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-17 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-16 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-16 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-16 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-16 Version: patch
|
||||
- Metering.
|
||||
|
||||
2020-10-16 Version: patch
|
||||
- Supported AndroidNotificationNotifyId for Push and MassPush.
|
||||
- Supported iOSNotificationCollapseId for Push and MassPush.
|
||||
|
||||
@@ -131,9 +131,19 @@ RoaServiceClient::buildHttpRequest(const std::string &endpoint,
|
||||
} else {
|
||||
if (msg.parameter("Content-Type").empty()) {
|
||||
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
auto body_params = msg.bodyParameters();
|
||||
std::stringstream sbody;
|
||||
for (const auto &p : body_params) {
|
||||
sbody << "&" << p.first << "=" << UrlEncode(p.second);
|
||||
}
|
||||
request.setBody(sbody.str().c_str(), sbody.str().size());
|
||||
request.setHeader("Content-Length", std::to_string(request.bodySize()));
|
||||
request.setHeader("Content-MD5",
|
||||
ComputeContentMD5(request.body(), request.bodySize()));
|
||||
} else {
|
||||
request.setHeader("Content-MD5",
|
||||
ComputeContentMD5(msg.content(), msg.contentSize()));
|
||||
}
|
||||
request.setHeader("Content-MD5",
|
||||
ComputeContentMD5(msg.content(), msg.contentSize()));
|
||||
}
|
||||
|
||||
std::time_t t = std::time(nullptr);
|
||||
|
||||
@@ -21,11 +21,15 @@ set(metering_public_header
|
||||
include/alibabacloud/metering/MeteringExport.h )
|
||||
|
||||
set(metering_public_header_model
|
||||
include/alibabacloud/metering/model/PostDataRequest.h
|
||||
include/alibabacloud/metering/model/PostDataResult.h
|
||||
include/alibabacloud/metering/model/SyncDataRequest.h
|
||||
include/alibabacloud/metering/model/SyncDataResult.h )
|
||||
|
||||
set(metering_src
|
||||
src/MeteringClient.cc
|
||||
src/model/PostDataRequest.cc
|
||||
src/model/PostDataResult.cc
|
||||
src/model/SyncDataRequest.cc
|
||||
src/model/SyncDataResult.cc )
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <alibabacloud/core/EndpointProvider.h>
|
||||
#include <alibabacloud/core/RoaServiceClient.h>
|
||||
#include "MeteringExport.h"
|
||||
#include "model/PostDataRequest.h"
|
||||
#include "model/PostDataResult.h"
|
||||
#include "model/SyncDataRequest.h"
|
||||
#include "model/SyncDataResult.h"
|
||||
|
||||
@@ -33,6 +35,9 @@ namespace AlibabaCloud
|
||||
class ALIBABACLOUD_METERING_EXPORT MeteringClient : public RoaServiceClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, Model::PostDataResult> PostDataOutcome;
|
||||
typedef std::future<PostDataOutcome> PostDataOutcomeCallable;
|
||||
typedef std::function<void(const MeteringClient*, const Model::PostDataRequest&, const PostDataOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> PostDataAsyncHandler;
|
||||
typedef Outcome<Error, Model::SyncDataResult> SyncDataOutcome;
|
||||
typedef std::future<SyncDataOutcome> SyncDataOutcomeCallable;
|
||||
typedef std::function<void(const MeteringClient*, const Model::SyncDataRequest&, const SyncDataOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SyncDataAsyncHandler;
|
||||
@@ -41,6 +46,9 @@ namespace AlibabaCloud
|
||||
MeteringClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
MeteringClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
~MeteringClient();
|
||||
PostDataOutcome postData(const Model::PostDataRequest &request)const;
|
||||
void postDataAsync(const Model::PostDataRequest& request, const PostDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
PostDataOutcomeCallable postDataCallable(const Model::PostDataRequest& request) const;
|
||||
SyncDataOutcome syncData(const Model::SyncDataRequest &request)const;
|
||||
void syncDataAsync(const Model::SyncDataRequest& request, const SyncDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
SyncDataOutcomeCallable syncDataCallable(const Model::SyncDataRequest& request) const;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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_METERING_MODEL_POSTDATAREQUEST_H_
|
||||
#define ALIBABACLOUD_METERING_MODEL_POSTDATAREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RoaServiceRequest.h>
|
||||
#include <alibabacloud/metering/MeteringExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Metering
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_METERING_EXPORT PostDataRequest : public RoaServiceRequest
|
||||
{
|
||||
|
||||
public:
|
||||
PostDataRequest();
|
||||
~PostDataRequest();
|
||||
|
||||
std::string getInstanceId()const;
|
||||
void setInstanceId(const std::string& instanceId);
|
||||
std::string getData()const;
|
||||
void setData(const std::string& data);
|
||||
std::string getDataType()const;
|
||||
void setDataType(const std::string& dataType);
|
||||
std::string getEndTime()const;
|
||||
void setEndTime(const std::string& endTime);
|
||||
std::string getStartTime()const;
|
||||
void setStartTime(const std::string& startTime);
|
||||
std::string getCommodityCode()const;
|
||||
void setCommodityCode(const std::string& commodityCode);
|
||||
std::string getRegion()const;
|
||||
void setRegion(const std::string& region);
|
||||
std::string getServiceId()const;
|
||||
void setServiceId(const std::string& serviceId);
|
||||
std::string getUserId()const;
|
||||
void setUserId(const std::string& userId);
|
||||
|
||||
private:
|
||||
std::string instanceId_;
|
||||
std::string data_;
|
||||
std::string dataType_;
|
||||
std::string endTime_;
|
||||
std::string startTime_;
|
||||
std::string commodityCode_;
|
||||
std::string region_;
|
||||
std::string serviceId_;
|
||||
std::string userId_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_METERING_MODEL_POSTDATAREQUEST_H_
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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_METERING_MODEL_POSTDATARESULT_H_
|
||||
#define ALIBABACLOUD_METERING_MODEL_POSTDATARESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/metering/MeteringExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Metering
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_METERING_EXPORT PostDataResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
PostDataResult();
|
||||
explicit PostDataResult(const std::string &payload);
|
||||
~PostDataResult();
|
||||
bool getData()const;
|
||||
std::string getErrMessage()const;
|
||||
bool getSuccess()const;
|
||||
int getErrCode()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
bool data_;
|
||||
std::string errMessage_;
|
||||
bool success_;
|
||||
int errCode_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_METERING_MODEL_POSTDATARESULT_H_
|
||||
@@ -49,6 +49,8 @@ namespace AlibabaCloud
|
||||
void setCommodityCode(const std::string& commodityCode);
|
||||
std::string getRegion()const;
|
||||
void setRegion(const std::string& region);
|
||||
std::string getServiceId()const;
|
||||
void setServiceId(const std::string& serviceId);
|
||||
std::string getUserId()const;
|
||||
void setUserId(const std::string& userId);
|
||||
|
||||
@@ -60,6 +62,7 @@ namespace AlibabaCloud
|
||||
std::string startTime_;
|
||||
std::string commodityCode_;
|
||||
std::string region_;
|
||||
std::string serviceId_;
|
||||
std::string userId_;
|
||||
|
||||
};
|
||||
|
||||
@@ -51,6 +51,42 @@ MeteringClient::MeteringClient(const std::string & accessKeyId, const std::strin
|
||||
MeteringClient::~MeteringClient()
|
||||
{}
|
||||
|
||||
MeteringClient::PostDataOutcome MeteringClient::postData(const PostDataRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return PostDataOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return PostDataOutcome(PostDataResult(outcome.result()));
|
||||
else
|
||||
return PostDataOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void MeteringClient::postDataAsync(const PostDataRequest& request, const PostDataAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, postData(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
MeteringClient::PostDataOutcomeCallable MeteringClient::postDataCallable(const PostDataRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<PostDataOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->postData(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
MeteringClient::SyncDataOutcome MeteringClient::syncData(const SyncDataRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
|
||||
129
metering/src/model/PostDataRequest.cc
Normal file
129
metering/src/model/PostDataRequest.cc
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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/metering/model/PostDataRequest.h>
|
||||
|
||||
using AlibabaCloud::Metering::Model::PostDataRequest;
|
||||
|
||||
PostDataRequest::PostDataRequest() :
|
||||
RoaServiceRequest("metering", "2020-09-21")
|
||||
{
|
||||
setResourcePath("/api/dataPost");
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
PostDataRequest::~PostDataRequest()
|
||||
{}
|
||||
|
||||
std::string PostDataRequest::getInstanceId()const
|
||||
{
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setInstanceId(const std::string& instanceId)
|
||||
{
|
||||
instanceId_ = instanceId;
|
||||
setBodyParameter("InstanceId", instanceId);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setData(const std::string& data)
|
||||
{
|
||||
data_ = data;
|
||||
setBodyParameter("Data", data);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getDataType()const
|
||||
{
|
||||
return dataType_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setDataType(const std::string& dataType)
|
||||
{
|
||||
dataType_ = dataType;
|
||||
setBodyParameter("DataType", dataType);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getEndTime()const
|
||||
{
|
||||
return endTime_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setEndTime(const std::string& endTime)
|
||||
{
|
||||
endTime_ = endTime;
|
||||
setBodyParameter("EndTime", endTime);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getStartTime()const
|
||||
{
|
||||
return startTime_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setStartTime(const std::string& startTime)
|
||||
{
|
||||
startTime_ = startTime;
|
||||
setBodyParameter("StartTime", startTime);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getCommodityCode()const
|
||||
{
|
||||
return commodityCode_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setCommodityCode(const std::string& commodityCode)
|
||||
{
|
||||
commodityCode_ = commodityCode;
|
||||
setBodyParameter("CommodityCode", commodityCode);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getRegion()const
|
||||
{
|
||||
return region_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setRegion(const std::string& region)
|
||||
{
|
||||
region_ = region;
|
||||
setBodyParameter("Region", region);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getServiceId()const
|
||||
{
|
||||
return serviceId_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setServiceId(const std::string& serviceId)
|
||||
{
|
||||
serviceId_ = serviceId;
|
||||
setBodyParameter("ServiceId", serviceId);
|
||||
}
|
||||
|
||||
std::string PostDataRequest::getUserId()const
|
||||
{
|
||||
return userId_;
|
||||
}
|
||||
|
||||
void PostDataRequest::setUserId(const std::string& userId)
|
||||
{
|
||||
userId_ = userId;
|
||||
setBodyParameter("UserId", userId);
|
||||
}
|
||||
|
||||
72
metering/src/model/PostDataResult.cc
Normal file
72
metering/src/model/PostDataResult.cc
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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/metering/model/PostDataResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Metering;
|
||||
using namespace AlibabaCloud::Metering::Model;
|
||||
|
||||
PostDataResult::PostDataResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
PostDataResult::PostDataResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
PostDataResult::~PostDataResult()
|
||||
{}
|
||||
|
||||
void PostDataResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["Success"].isNull())
|
||||
success_ = value["Success"].asString() == "true";
|
||||
if(!value["Data"].isNull())
|
||||
data_ = value["Data"].asString() == "true";
|
||||
if(!value["ErrCode"].isNull())
|
||||
errCode_ = std::stoi(value["ErrCode"].asString());
|
||||
if(!value["ErrMessage"].isNull())
|
||||
errMessage_ = value["ErrMessage"].asString();
|
||||
|
||||
}
|
||||
|
||||
bool PostDataResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
std::string PostDataResult::getErrMessage()const
|
||||
{
|
||||
return errMessage_;
|
||||
}
|
||||
|
||||
bool PostDataResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
int PostDataResult::getErrCode()const
|
||||
{
|
||||
return errCode_;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,17 @@ void SyncDataRequest::setRegion(const std::string& region)
|
||||
setParameter("Region", region);
|
||||
}
|
||||
|
||||
std::string SyncDataRequest::getServiceId()const
|
||||
{
|
||||
return serviceId_;
|
||||
}
|
||||
|
||||
void SyncDataRequest::setServiceId(const std::string& serviceId)
|
||||
{
|
||||
serviceId_ = serviceId;
|
||||
setParameter("ServiceId", serviceId);
|
||||
}
|
||||
|
||||
std::string SyncDataRequest::getUserId()const
|
||||
{
|
||||
return userId_;
|
||||
|
||||
Reference in New Issue
Block a user