Add translate api.

This commit is contained in:
sdk-team
2020-02-27 23:58:16 +08:00
parent 140879338b
commit ca9bc6363b
19 changed files with 910 additions and 13 deletions

View File

@@ -1,3 +1,6 @@
2020-02-27 Version: 1.36.293
- Add translate api.
2020-02-27 Version: 1.36.292
- Release Ft SDK.

View File

@@ -1 +1 @@
1.36.292
1.36.293

View File

@@ -21,6 +21,12 @@ set(alimt_public_header
include/alibabacloud/alimt/AlimtExport.h )
set(alimt_public_header_model
include/alibabacloud/alimt/model/CreateDocTranslateTaskRequest.h
include/alibabacloud/alimt/model/CreateDocTranslateTaskResult.h
include/alibabacloud/alimt/model/GetDocTranslateTaskRequest.h
include/alibabacloud/alimt/model/GetDocTranslateTaskResult.h
include/alibabacloud/alimt/model/TranslateRequest.h
include/alibabacloud/alimt/model/TranslateResult.h
include/alibabacloud/alimt/model/TranslateECommerceRequest.h
include/alibabacloud/alimt/model/TranslateECommerceResult.h
include/alibabacloud/alimt/model/TranslateGeneralRequest.h
@@ -28,6 +34,12 @@ set(alimt_public_header_model
set(alimt_src
src/AlimtClient.cc
src/model/CreateDocTranslateTaskRequest.cc
src/model/CreateDocTranslateTaskResult.cc
src/model/GetDocTranslateTaskRequest.cc
src/model/GetDocTranslateTaskResult.cc
src/model/TranslateRequest.cc
src/model/TranslateResult.cc
src/model/TranslateECommerceRequest.cc
src/model/TranslateECommerceResult.cc
src/model/TranslateGeneralRequest.cc

View File

@@ -22,6 +22,12 @@
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#include "AlimtExport.h"
#include "model/CreateDocTranslateTaskRequest.h"
#include "model/CreateDocTranslateTaskResult.h"
#include "model/GetDocTranslateTaskRequest.h"
#include "model/GetDocTranslateTaskResult.h"
#include "model/TranslateRequest.h"
#include "model/TranslateResult.h"
#include "model/TranslateECommerceRequest.h"
#include "model/TranslateECommerceResult.h"
#include "model/TranslateGeneralRequest.h"
@@ -35,6 +41,15 @@ namespace AlibabaCloud
class ALIBABACLOUD_ALIMT_EXPORT AlimtClient : public RpcServiceClient
{
public:
typedef Outcome<Error, Model::CreateDocTranslateTaskResult> CreateDocTranslateTaskOutcome;
typedef std::future<CreateDocTranslateTaskOutcome> CreateDocTranslateTaskOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::CreateDocTranslateTaskRequest&, const CreateDocTranslateTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> CreateDocTranslateTaskAsyncHandler;
typedef Outcome<Error, Model::GetDocTranslateTaskResult> GetDocTranslateTaskOutcome;
typedef std::future<GetDocTranslateTaskOutcome> GetDocTranslateTaskOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::GetDocTranslateTaskRequest&, const GetDocTranslateTaskOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetDocTranslateTaskAsyncHandler;
typedef Outcome<Error, Model::TranslateResult> TranslateOutcome;
typedef std::future<TranslateOutcome> TranslateOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::TranslateRequest&, const TranslateOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TranslateAsyncHandler;
typedef Outcome<Error, Model::TranslateECommerceResult> TranslateECommerceOutcome;
typedef std::future<TranslateECommerceOutcome> TranslateECommerceOutcomeCallable;
typedef std::function<void(const AlimtClient*, const Model::TranslateECommerceRequest&, const TranslateECommerceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> TranslateECommerceAsyncHandler;
@@ -46,6 +61,15 @@ namespace AlibabaCloud
AlimtClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
AlimtClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~AlimtClient();
CreateDocTranslateTaskOutcome createDocTranslateTask(const Model::CreateDocTranslateTaskRequest &request)const;
void createDocTranslateTaskAsync(const Model::CreateDocTranslateTaskRequest& request, const CreateDocTranslateTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
CreateDocTranslateTaskOutcomeCallable createDocTranslateTaskCallable(const Model::CreateDocTranslateTaskRequest& request) const;
GetDocTranslateTaskOutcome getDocTranslateTask(const Model::GetDocTranslateTaskRequest &request)const;
void getDocTranslateTaskAsync(const Model::GetDocTranslateTaskRequest& request, const GetDocTranslateTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetDocTranslateTaskOutcomeCallable getDocTranslateTaskCallable(const Model::GetDocTranslateTaskRequest& request) const;
TranslateOutcome translate(const Model::TranslateRequest &request)const;
void translateAsync(const Model::TranslateRequest& request, const TranslateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TranslateOutcomeCallable translateCallable(const Model::TranslateRequest& request) const;
TranslateECommerceOutcome translateECommerce(const Model::TranslateECommerceRequest &request)const;
void translateECommerceAsync(const Model::TranslateECommerceRequest& request, const TranslateECommerceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
TranslateECommerceOutcomeCallable translateECommerceCallable(const Model::TranslateECommerceRequest& request) const;

View File

@@ -0,0 +1,63 @@
/*
* 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_ALIMT_MODEL_CREATEDOCTRANSLATETASKREQUEST_H_
#define ALIBABACLOUD_ALIMT_MODEL_CREATEDOCTRANSLATETASKREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT CreateDocTranslateTaskRequest : public RpcServiceRequest
{
public:
CreateDocTranslateTaskRequest();
~CreateDocTranslateTaskRequest();
std::string getSourceLanguage()const;
void setSourceLanguage(const std::string& sourceLanguage);
std::string getClientToken()const;
void setClientToken(const std::string& clientToken);
std::string getScene()const;
void setScene(const std::string& scene);
std::string getFileUrl()const;
void setFileUrl(const std::string& fileUrl);
std::string getTargetLanguage()const;
void setTargetLanguage(const std::string& targetLanguage);
std::string getCallbackUrl()const;
void setCallbackUrl(const std::string& callbackUrl);
private:
std::string sourceLanguage_;
std::string clientToken_;
std::string scene_;
std::string fileUrl_;
std::string targetLanguage_;
std::string callbackUrl_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_CREATEDOCTRANSLATETASKREQUEST_H_

View File

@@ -0,0 +1,53 @@
/*
* 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_ALIMT_MODEL_CREATEDOCTRANSLATETASKRESULT_H_
#define ALIBABACLOUD_ALIMT_MODEL_CREATEDOCTRANSLATETASKRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT CreateDocTranslateTaskResult : public ServiceResult
{
public:
CreateDocTranslateTaskResult();
explicit CreateDocTranslateTaskResult(const std::string &payload);
~CreateDocTranslateTaskResult();
std::string getStatus()const;
std::string getTaskId()const;
protected:
void parse(const std::string &payload);
private:
std::string status_;
std::string taskId_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_CREATEDOCTRANSLATETASKRESULT_H_

View File

@@ -0,0 +1,48 @@
/*
* 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_ALIMT_MODEL_GETDOCTRANSLATETASKREQUEST_H_
#define ALIBABACLOUD_ALIMT_MODEL_GETDOCTRANSLATETASKREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT GetDocTranslateTaskRequest : public RpcServiceRequest
{
public:
GetDocTranslateTaskRequest();
~GetDocTranslateTaskRequest();
std::string getTaskId()const;
void setTaskId(const std::string& taskId);
private:
std::string taskId_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_GETDOCTRANSLATETASKREQUEST_H_

View File

@@ -0,0 +1,55 @@
/*
* 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_ALIMT_MODEL_GETDOCTRANSLATETASKRESULT_H_
#define ALIBABACLOUD_ALIMT_MODEL_GETDOCTRANSLATETASKRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT GetDocTranslateTaskResult : public ServiceResult
{
public:
GetDocTranslateTaskResult();
explicit GetDocTranslateTaskResult(const std::string &payload);
~GetDocTranslateTaskResult();
std::string getStatus()const;
std::string getTaskId()const;
std::string getTranslateFileUrl()const;
protected:
void parse(const std::string &payload);
private:
std::string status_;
std::string taskId_;
std::string translateFileUrl_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_GETDOCTRANSLATETASKRESULT_H_

View File

@@ -0,0 +1,60 @@
/*
* 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_ALIMT_MODEL_TRANSLATEREQUEST_H_
#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATEREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT TranslateRequest : public RpcServiceRequest
{
public:
TranslateRequest();
~TranslateRequest();
std::string getSourceLanguage()const;
void setSourceLanguage(const std::string& sourceLanguage);
std::string getSourceText()const;
void setSourceText(const std::string& sourceText);
std::string getFormatType()const;
void setFormatType(const std::string& formatType);
std::string getScene()const;
void setScene(const std::string& scene);
std::string getTargetLanguage()const;
void setTargetLanguage(const std::string& targetLanguage);
private:
std::string sourceLanguage_;
std::string sourceText_;
std::string formatType_;
std::string scene_;
std::string targetLanguage_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATEREQUEST_H_

View File

@@ -0,0 +1,59 @@
/*
* 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_ALIMT_MODEL_TRANSLATERESULT_H_
#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/alimt/AlimtExport.h>
namespace AlibabaCloud
{
namespace Alimt
{
namespace Model
{
class ALIBABACLOUD_ALIMT_EXPORT TranslateResult : public ServiceResult
{
public:
struct Data
{
std::string translated;
};
TranslateResult();
explicit TranslateResult(const std::string &payload);
~TranslateResult();
std::string getMessage()const;
Data getData()const;
int getCode()const;
protected:
void parse(const std::string &payload);
private:
std::string message_;
Data data_;
int code_;
};
}
}
}
#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATERESULT_H_

View File

@@ -51,6 +51,114 @@ AlimtClient::AlimtClient(const std::string & accessKeyId, const std::string & ac
AlimtClient::~AlimtClient()
{}
AlimtClient::CreateDocTranslateTaskOutcome AlimtClient::createDocTranslateTask(const CreateDocTranslateTaskRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return CreateDocTranslateTaskOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return CreateDocTranslateTaskOutcome(CreateDocTranslateTaskResult(outcome.result()));
else
return CreateDocTranslateTaskOutcome(outcome.error());
}
void AlimtClient::createDocTranslateTaskAsync(const CreateDocTranslateTaskRequest& request, const CreateDocTranslateTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, createDocTranslateTask(request), context);
};
asyncExecute(new Runnable(fn));
}
AlimtClient::CreateDocTranslateTaskOutcomeCallable AlimtClient::createDocTranslateTaskCallable(const CreateDocTranslateTaskRequest &request) const
{
auto task = std::make_shared<std::packaged_task<CreateDocTranslateTaskOutcome()>>(
[this, request]()
{
return this->createDocTranslateTask(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
AlimtClient::GetDocTranslateTaskOutcome AlimtClient::getDocTranslateTask(const GetDocTranslateTaskRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return GetDocTranslateTaskOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return GetDocTranslateTaskOutcome(GetDocTranslateTaskResult(outcome.result()));
else
return GetDocTranslateTaskOutcome(outcome.error());
}
void AlimtClient::getDocTranslateTaskAsync(const GetDocTranslateTaskRequest& request, const GetDocTranslateTaskAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, getDocTranslateTask(request), context);
};
asyncExecute(new Runnable(fn));
}
AlimtClient::GetDocTranslateTaskOutcomeCallable AlimtClient::getDocTranslateTaskCallable(const GetDocTranslateTaskRequest &request) const
{
auto task = std::make_shared<std::packaged_task<GetDocTranslateTaskOutcome()>>(
[this, request]()
{
return this->getDocTranslateTask(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
AlimtClient::TranslateOutcome AlimtClient::translate(const TranslateRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return TranslateOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return TranslateOutcome(TranslateResult(outcome.result()));
else
return TranslateOutcome(outcome.error());
}
void AlimtClient::translateAsync(const TranslateRequest& request, const TranslateAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, translate(request), context);
};
asyncExecute(new Runnable(fn));
}
AlimtClient::TranslateOutcomeCallable AlimtClient::translateCallable(const TranslateRequest &request) const
{
auto task = std::make_shared<std::packaged_task<TranslateOutcome()>>(
[this, request]()
{
return this->translate(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
AlimtClient::TranslateECommerceOutcome AlimtClient::translateECommerce(const TranslateECommerceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

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.
*/
#include <alibabacloud/alimt/model/CreateDocTranslateTaskRequest.h>
using AlibabaCloud::Alimt::Model::CreateDocTranslateTaskRequest;
CreateDocTranslateTaskRequest::CreateDocTranslateTaskRequest() :
RpcServiceRequest("alimt", "2018-10-12", "CreateDocTranslateTask")
{
setMethod(HttpRequest::Method::POST);
}
CreateDocTranslateTaskRequest::~CreateDocTranslateTaskRequest()
{}
std::string CreateDocTranslateTaskRequest::getSourceLanguage()const
{
return sourceLanguage_;
}
void CreateDocTranslateTaskRequest::setSourceLanguage(const std::string& sourceLanguage)
{
sourceLanguage_ = sourceLanguage;
setBodyParameter("SourceLanguage", sourceLanguage);
}
std::string CreateDocTranslateTaskRequest::getClientToken()const
{
return clientToken_;
}
void CreateDocTranslateTaskRequest::setClientToken(const std::string& clientToken)
{
clientToken_ = clientToken;
setBodyParameter("ClientToken", clientToken);
}
std::string CreateDocTranslateTaskRequest::getScene()const
{
return scene_;
}
void CreateDocTranslateTaskRequest::setScene(const std::string& scene)
{
scene_ = scene;
setBodyParameter("Scene", scene);
}
std::string CreateDocTranslateTaskRequest::getFileUrl()const
{
return fileUrl_;
}
void CreateDocTranslateTaskRequest::setFileUrl(const std::string& fileUrl)
{
fileUrl_ = fileUrl;
setBodyParameter("FileUrl", fileUrl);
}
std::string CreateDocTranslateTaskRequest::getTargetLanguage()const
{
return targetLanguage_;
}
void CreateDocTranslateTaskRequest::setTargetLanguage(const std::string& targetLanguage)
{
targetLanguage_ = targetLanguage;
setBodyParameter("TargetLanguage", targetLanguage);
}
std::string CreateDocTranslateTaskRequest::getCallbackUrl()const
{
return callbackUrl_;
}
void CreateDocTranslateTaskRequest::setCallbackUrl(const std::string& callbackUrl)
{
callbackUrl_ = callbackUrl;
setBodyParameter("CallbackUrl", callbackUrl);
}

View File

@@ -0,0 +1,58 @@
/*
* 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/alimt/model/CreateDocTranslateTaskResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Alimt;
using namespace AlibabaCloud::Alimt::Model;
CreateDocTranslateTaskResult::CreateDocTranslateTaskResult() :
ServiceResult()
{}
CreateDocTranslateTaskResult::CreateDocTranslateTaskResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
CreateDocTranslateTaskResult::~CreateDocTranslateTaskResult()
{}
void CreateDocTranslateTaskResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["TaskId"].isNull())
taskId_ = value["TaskId"].asString();
if(!value["Status"].isNull())
status_ = value["Status"].asString();
}
std::string CreateDocTranslateTaskResult::getStatus()const
{
return status_;
}
std::string CreateDocTranslateTaskResult::getTaskId()const
{
return taskId_;
}

View File

@@ -0,0 +1,40 @@
/*
* 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/alimt/model/GetDocTranslateTaskRequest.h>
using AlibabaCloud::Alimt::Model::GetDocTranslateTaskRequest;
GetDocTranslateTaskRequest::GetDocTranslateTaskRequest() :
RpcServiceRequest("alimt", "2018-10-12", "GetDocTranslateTask")
{
setMethod(HttpRequest::Method::GET);
}
GetDocTranslateTaskRequest::~GetDocTranslateTaskRequest()
{}
std::string GetDocTranslateTaskRequest::getTaskId()const
{
return taskId_;
}
void GetDocTranslateTaskRequest::setTaskId(const std::string& taskId)
{
taskId_ = taskId;
setParameter("TaskId", taskId);
}

View File

@@ -0,0 +1,65 @@
/*
* 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/alimt/model/GetDocTranslateTaskResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Alimt;
using namespace AlibabaCloud::Alimt::Model;
GetDocTranslateTaskResult::GetDocTranslateTaskResult() :
ServiceResult()
{}
GetDocTranslateTaskResult::GetDocTranslateTaskResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
GetDocTranslateTaskResult::~GetDocTranslateTaskResult()
{}
void GetDocTranslateTaskResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
if(!value["TaskId"].isNull())
taskId_ = value["TaskId"].asString();
if(!value["Status"].isNull())
status_ = value["Status"].asString();
if(!value["TranslateFileUrl"].isNull())
translateFileUrl_ = value["TranslateFileUrl"].asString();
}
std::string GetDocTranslateTaskResult::getStatus()const
{
return status_;
}
std::string GetDocTranslateTaskResult::getTaskId()const
{
return taskId_;
}
std::string GetDocTranslateTaskResult::getTranslateFileUrl()const
{
return translateFileUrl_;
}

View File

@@ -20,7 +20,9 @@ using AlibabaCloud::Alimt::Model::TranslateECommerceRequest;
TranslateECommerceRequest::TranslateECommerceRequest() :
RpcServiceRequest("alimt", "2018-10-12", "TranslateECommerce")
{}
{
setMethod(HttpRequest::Method::POST);
}
TranslateECommerceRequest::~TranslateECommerceRequest()
{}
@@ -33,7 +35,7 @@ std::string TranslateECommerceRequest::getSourceLanguage()const
void TranslateECommerceRequest::setSourceLanguage(const std::string& sourceLanguage)
{
sourceLanguage_ = sourceLanguage;
setCoreParameter("SourceLanguage", sourceLanguage);
setBodyParameter("SourceLanguage", sourceLanguage);
}
std::string TranslateECommerceRequest::getSourceText()const
@@ -44,7 +46,7 @@ std::string TranslateECommerceRequest::getSourceText()const
void TranslateECommerceRequest::setSourceText(const std::string& sourceText)
{
sourceText_ = sourceText;
setCoreParameter("SourceText", sourceText);
setBodyParameter("SourceText", sourceText);
}
std::string TranslateECommerceRequest::getFormatType()const
@@ -55,7 +57,7 @@ std::string TranslateECommerceRequest::getFormatType()const
void TranslateECommerceRequest::setFormatType(const std::string& formatType)
{
formatType_ = formatType;
setCoreParameter("FormatType", formatType);
setBodyParameter("FormatType", formatType);
}
std::string TranslateECommerceRequest::getScene()const
@@ -66,7 +68,7 @@ std::string TranslateECommerceRequest::getScene()const
void TranslateECommerceRequest::setScene(const std::string& scene)
{
scene_ = scene;
setCoreParameter("Scene", scene);
setBodyParameter("Scene", scene);
}
std::string TranslateECommerceRequest::getTargetLanguage()const
@@ -77,6 +79,6 @@ std::string TranslateECommerceRequest::getTargetLanguage()const
void TranslateECommerceRequest::setTargetLanguage(const std::string& targetLanguage)
{
targetLanguage_ = targetLanguage;
setCoreParameter("TargetLanguage", targetLanguage);
setBodyParameter("TargetLanguage", targetLanguage);
}

View File

@@ -20,7 +20,9 @@ using AlibabaCloud::Alimt::Model::TranslateGeneralRequest;
TranslateGeneralRequest::TranslateGeneralRequest() :
RpcServiceRequest("alimt", "2018-10-12", "TranslateGeneral")
{}
{
setMethod(HttpRequest::Method::POST);
}
TranslateGeneralRequest::~TranslateGeneralRequest()
{}
@@ -33,7 +35,7 @@ std::string TranslateGeneralRequest::getSourceLanguage()const
void TranslateGeneralRequest::setSourceLanguage(const std::string& sourceLanguage)
{
sourceLanguage_ = sourceLanguage;
setCoreParameter("SourceLanguage", sourceLanguage);
setBodyParameter("SourceLanguage", sourceLanguage);
}
std::string TranslateGeneralRequest::getSourceText()const
@@ -44,7 +46,7 @@ std::string TranslateGeneralRequest::getSourceText()const
void TranslateGeneralRequest::setSourceText(const std::string& sourceText)
{
sourceText_ = sourceText;
setCoreParameter("SourceText", sourceText);
setBodyParameter("SourceText", sourceText);
}
std::string TranslateGeneralRequest::getFormatType()const
@@ -55,7 +57,7 @@ std::string TranslateGeneralRequest::getFormatType()const
void TranslateGeneralRequest::setFormatType(const std::string& formatType)
{
formatType_ = formatType;
setCoreParameter("FormatType", formatType);
setBodyParameter("FormatType", formatType);
}
std::string TranslateGeneralRequest::getScene()const
@@ -66,7 +68,7 @@ std::string TranslateGeneralRequest::getScene()const
void TranslateGeneralRequest::setScene(const std::string& scene)
{
scene_ = scene;
setCoreParameter("Scene", scene);
setBodyParameter("Scene", scene);
}
std::string TranslateGeneralRequest::getTargetLanguage()const
@@ -77,6 +79,6 @@ std::string TranslateGeneralRequest::getTargetLanguage()const
void TranslateGeneralRequest::setTargetLanguage(const std::string& targetLanguage)
{
targetLanguage_ = targetLanguage;
setCoreParameter("TargetLanguage", targetLanguage);
setBodyParameter("TargetLanguage", targetLanguage);
}

View File

@@ -0,0 +1,84 @@
/*
* 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/alimt/model/TranslateRequest.h>
using AlibabaCloud::Alimt::Model::TranslateRequest;
TranslateRequest::TranslateRequest() :
RpcServiceRequest("alimt", "2018-10-12", "Translate")
{
setMethod(HttpRequest::Method::POST);
}
TranslateRequest::~TranslateRequest()
{}
std::string TranslateRequest::getSourceLanguage()const
{
return sourceLanguage_;
}
void TranslateRequest::setSourceLanguage(const std::string& sourceLanguage)
{
sourceLanguage_ = sourceLanguage;
setBodyParameter("SourceLanguage", sourceLanguage);
}
std::string TranslateRequest::getSourceText()const
{
return sourceText_;
}
void TranslateRequest::setSourceText(const std::string& sourceText)
{
sourceText_ = sourceText;
setBodyParameter("SourceText", sourceText);
}
std::string TranslateRequest::getFormatType()const
{
return formatType_;
}
void TranslateRequest::setFormatType(const std::string& formatType)
{
formatType_ = formatType;
setBodyParameter("FormatType", formatType);
}
std::string TranslateRequest::getScene()const
{
return scene_;
}
void TranslateRequest::setScene(const std::string& scene)
{
scene_ = scene;
setBodyParameter("Scene", scene);
}
std::string TranslateRequest::getTargetLanguage()const
{
return targetLanguage_;
}
void TranslateRequest::setTargetLanguage(const std::string& targetLanguage)
{
targetLanguage_ = targetLanguage;
setBodyParameter("TargetLanguage", targetLanguage);
}

View File

@@ -0,0 +1,66 @@
/*
* 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/alimt/model/TranslateResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Alimt;
using namespace AlibabaCloud::Alimt::Model;
TranslateResult::TranslateResult() :
ServiceResult()
{}
TranslateResult::TranslateResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
TranslateResult::~TranslateResult()
{}
void TranslateResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
if(!dataNode["Translated"].isNull())
data_.translated = dataNode["Translated"].asString();
if(!value["Code"].isNull())
code_ = std::stoi(value["Code"].asString());
if(!value["Message"].isNull())
message_ = value["Message"].asString();
}
std::string TranslateResult::getMessage()const
{
return message_;
}
TranslateResult::Data TranslateResult::getData()const
{
return data_;
}
int TranslateResult::getCode()const
{
return code_;
}