From 66cfddf93054c247a72bfdb10eacff01b5b87802 Mon Sep 17 00:00:00 2001 From: "yixiong.jxy" Date: Fri, 16 Nov 2018 15:49:36 +0800 Subject: [PATCH] =?UTF-8?q?ALIMT=20SDK=20Auto=20Released=20By=20xulei.xl,V?= =?UTF-8?q?ersion=EF=BC=9A1.33.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yixiong.jxy --- CHANGELOG | 3 + CMakeLists.txt | 3 +- VERSION | 2 +- alimt/CMakeLists.txt | 90 +++++++++++++ .../include/alibabacloud/alimt/AlimtClient.h | 62 +++++++++ .../include/alibabacloud/alimt/AlimtExport.h | 32 +++++ .../alimt/model/TranslateECommerceRequest.h | 57 ++++++++ .../alimt/model/TranslateECommerceResult.h | 59 +++++++++ .../alimt/model/TranslateGeneralRequest.h | 57 ++++++++ .../alimt/model/TranslateGeneralResult.h | 59 +++++++++ alimt/src/AlimtClient.cc | 125 ++++++++++++++++++ alimt/src/model/TranslateECommerceRequest.cc | 71 ++++++++++ alimt/src/model/TranslateECommerceResult.cc | 67 ++++++++++ alimt/src/model/TranslateGeneralRequest.cc | 71 ++++++++++ alimt/src/model/TranslateGeneralResult.cc | 67 ++++++++++ 15 files changed, 823 insertions(+), 2 deletions(-) create mode 100644 alimt/CMakeLists.txt create mode 100644 alimt/include/alibabacloud/alimt/AlimtClient.h create mode 100644 alimt/include/alibabacloud/alimt/AlimtExport.h create mode 100644 alimt/include/alibabacloud/alimt/model/TranslateECommerceRequest.h create mode 100644 alimt/include/alibabacloud/alimt/model/TranslateECommerceResult.h create mode 100644 alimt/include/alibabacloud/alimt/model/TranslateGeneralRequest.h create mode 100644 alimt/include/alibabacloud/alimt/model/TranslateGeneralResult.h create mode 100644 alimt/src/AlimtClient.cc create mode 100644 alimt/src/model/TranslateECommerceRequest.cc create mode 100644 alimt/src/model/TranslateECommerceResult.cc create mode 100644 alimt/src/model/TranslateGeneralRequest.cc create mode 100644 alimt/src/model/TranslateGeneralResult.cc diff --git a/CHANGELOG b/CHANGELOG index d34470349..ffb9f6ba7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2018-11-16 Version: 1.33.1 +1, update version + 2018-11-15 Version: 1.33.0 1, ECS support ipv6Address diff --git a/CMakeLists.txt b/CMakeLists.txt index 1837095d4..078548580 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,4 +91,5 @@ add_subdirectory(vod) add_subdirectory(ccs) add_subdirectory(saf) add_subdirectory(arms) -add_subdirectory(lubancloud) \ No newline at end of file +add_subdirectory(lubancloud) +add_subdirectory(alimt) \ No newline at end of file diff --git a/VERSION b/VERSION index f0fed9186..9e9fac324 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.33.0 \ No newline at end of file +1.33.1 \ No newline at end of file diff --git a/alimt/CMakeLists.txt b/alimt/CMakeLists.txt new file mode 100644 index 000000000..bec905e49 --- /dev/null +++ b/alimt/CMakeLists.txt @@ -0,0 +1,90 @@ +# +# 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. +# + +set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +set(alimt_public_header + include/alibabacloud/alimt/AlimtClient.h + include/alibabacloud/alimt/AlimtExport.h ) + +set(alimt_public_header_model + include/alibabacloud/alimt/model/TranslateECommerceRequest.h + include/alibabacloud/alimt/model/TranslateECommerceResult.h + include/alibabacloud/alimt/model/TranslateGeneralRequest.h + include/alibabacloud/alimt/model/TranslateGeneralResult.h ) + +set(alimt_src + src/AlimtClient.cc + src/model/TranslateECommerceRequest.cc + src/model/TranslateECommerceResult.cc + src/model/TranslateGeneralRequest.cc + src/model/TranslateGeneralResult.cc ) + +add_library(alimt ${LIB_TYPE} + ${alimt_public_header} + ${alimt_public_header_model} + ${alimt_src}) + +set_target_properties(alimt + PROPERTIES + LINKER_LANGUAGE CXX + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}alimt + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(alimt + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_ALIMT_LIBRARY) +endif() + +target_include_directories(alimt + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(alimt + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(alimt + jsoncpp) + target_include_directories(alimt + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(alimt + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(alimt + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(alimt + PRIVATE /usr/include/jsoncpp) + target_link_libraries(alimt + jsoncpp) +endif() + +install(FILES ${alimt_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/alimt) +install(FILES ${alimt_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/alimt/model) +install(TARGETS alimt + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/alimt/include/alibabacloud/alimt/AlimtClient.h b/alimt/include/alibabacloud/alimt/AlimtClient.h new file mode 100644 index 000000000..8011d1ad8 --- /dev/null +++ b/alimt/include/alibabacloud/alimt/AlimtClient.h @@ -0,0 +1,62 @@ +/* + * 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_ALIMTCLIENT_H_ +#define ALIBABACLOUD_ALIMT_ALIMTCLIENT_H_ + +#include +#include +#include +#include +#include "AlimtExport.h" +#include "model/TranslateECommerceRequest.h" +#include "model/TranslateECommerceResult.h" +#include "model/TranslateGeneralRequest.h" +#include "model/TranslateGeneralResult.h" + + +namespace AlibabaCloud +{ + namespace Alimt + { + class ALIBABACLOUD_ALIMT_EXPORT AlimtClient : public RpcServiceClient + { + public: + typedef Outcome TranslateECommerceOutcome; + typedef std::future TranslateECommerceOutcomeCallable; + typedef std::function&)> TranslateECommerceAsyncHandler; + typedef Outcome TranslateGeneralOutcome; + typedef std::future TranslateGeneralOutcomeCallable; + typedef std::function&)> TranslateGeneralAsyncHandler; + + AlimtClient(const Credentials &credentials, const ClientConfiguration &configuration); + AlimtClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + AlimtClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~AlimtClient(); + TranslateECommerceOutcome translateECommerce(const Model::TranslateECommerceRequest &request)const; + void translateECommerceAsync(const Model::TranslateECommerceRequest& request, const TranslateECommerceAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + TranslateECommerceOutcomeCallable translateECommerceCallable(const Model::TranslateECommerceRequest& request) const; + TranslateGeneralOutcome translateGeneral(const Model::TranslateGeneralRequest &request)const; + void translateGeneralAsync(const Model::TranslateGeneralRequest& request, const TranslateGeneralAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + TranslateGeneralOutcomeCallable translateGeneralCallable(const Model::TranslateGeneralRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_ALIMT_ALIMTCLIENT_H_ diff --git a/alimt/include/alibabacloud/alimt/AlimtExport.h b/alimt/include/alibabacloud/alimt/AlimtExport.h new file mode 100644 index 000000000..9f7b58bda --- /dev/null +++ b/alimt/include/alibabacloud/alimt/AlimtExport.h @@ -0,0 +1,32 @@ +/* + * 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_ALIMTEXPORT_H_ +#define ALIBABACLOUD_ALIMT_ALIMTEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_ALIMT_LIBRARY) +# define ALIBABACLOUD_ALIMT_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_ALIMT_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_ALIMT_EXPORT +#endif + +#endif // !ALIBABACLOUD_ALIMT_ALIMTEXPORT_H_ \ No newline at end of file diff --git a/alimt/include/alibabacloud/alimt/model/TranslateECommerceRequest.h b/alimt/include/alibabacloud/alimt/model/TranslateECommerceRequest.h new file mode 100644 index 000000000..5ed7a46af --- /dev/null +++ b/alimt/include/alibabacloud/alimt/model/TranslateECommerceRequest.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_ALIMT_MODEL_TRANSLATEECOMMERCEREQUEST_H_ +#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATEECOMMERCEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Alimt + { + namespace Model + { + class ALIBABACLOUD_ALIMT_EXPORT TranslateECommerceRequest : public RpcServiceRequest + { + + public: + TranslateECommerceRequest(); + ~TranslateECommerceRequest(); + + 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 getTargetLanguage()const; + void setTargetLanguage(const std::string& targetLanguage); + + private: + std::string sourceLanguage_; + std::string sourceText_; + std::string formatType_; + std::string targetLanguage_; + + }; + } + } +} +#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATEECOMMERCEREQUEST_H_ \ No newline at end of file diff --git a/alimt/include/alibabacloud/alimt/model/TranslateECommerceResult.h b/alimt/include/alibabacloud/alimt/model/TranslateECommerceResult.h new file mode 100644 index 000000000..058ad3367 --- /dev/null +++ b/alimt/include/alibabacloud/alimt/model/TranslateECommerceResult.h @@ -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_TRANSLATEECOMMERCERESULT_H_ +#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATEECOMMERCERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Alimt + { + namespace Model + { + class ALIBABACLOUD_ALIMT_EXPORT TranslateECommerceResult : public ServiceResult + { + public: + struct Data + { + std::string translated; + }; + + + TranslateECommerceResult(); + explicit TranslateECommerceResult(const std::string &payload); + ~TranslateECommerceResult(); + 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_TRANSLATEECOMMERCERESULT_H_ \ No newline at end of file diff --git a/alimt/include/alibabacloud/alimt/model/TranslateGeneralRequest.h b/alimt/include/alibabacloud/alimt/model/TranslateGeneralRequest.h new file mode 100644 index 000000000..8f4be6626 --- /dev/null +++ b/alimt/include/alibabacloud/alimt/model/TranslateGeneralRequest.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_ALIMT_MODEL_TRANSLATEGENERALREQUEST_H_ +#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATEGENERALREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Alimt + { + namespace Model + { + class ALIBABACLOUD_ALIMT_EXPORT TranslateGeneralRequest : public RpcServiceRequest + { + + public: + TranslateGeneralRequest(); + ~TranslateGeneralRequest(); + + 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 getTargetLanguage()const; + void setTargetLanguage(const std::string& targetLanguage); + + private: + std::string sourceLanguage_; + std::string sourceText_; + std::string formatType_; + std::string targetLanguage_; + + }; + } + } +} +#endif // !ALIBABACLOUD_ALIMT_MODEL_TRANSLATEGENERALREQUEST_H_ \ No newline at end of file diff --git a/alimt/include/alibabacloud/alimt/model/TranslateGeneralResult.h b/alimt/include/alibabacloud/alimt/model/TranslateGeneralResult.h new file mode 100644 index 000000000..dbaa3d6bd --- /dev/null +++ b/alimt/include/alibabacloud/alimt/model/TranslateGeneralResult.h @@ -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_TRANSLATEGENERALRESULT_H_ +#define ALIBABACLOUD_ALIMT_MODEL_TRANSLATEGENERALRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Alimt + { + namespace Model + { + class ALIBABACLOUD_ALIMT_EXPORT TranslateGeneralResult : public ServiceResult + { + public: + struct Data + { + std::string translated; + }; + + + TranslateGeneralResult(); + explicit TranslateGeneralResult(const std::string &payload); + ~TranslateGeneralResult(); + 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_TRANSLATEGENERALRESULT_H_ \ No newline at end of file diff --git a/alimt/src/AlimtClient.cc b/alimt/src/AlimtClient.cc new file mode 100644 index 000000000..2f70d5778 --- /dev/null +++ b/alimt/src/AlimtClient.cc @@ -0,0 +1,125 @@ +/* + * 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; +using namespace AlibabaCloud::Location; +using namespace AlibabaCloud::Alimt; +using namespace AlibabaCloud::Alimt::Model; + +namespace +{ + const std::string SERVICE_NAME = "alimt"; +} + +AlimtClient::AlimtClient(const Credentials &credentials, const ClientConfiguration &configuration) : + RpcServiceClient(SERVICE_NAME, std::make_shared(credentials), configuration) +{ + auto locationClient = std::make_shared(credentials, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "alimt"); +} + +AlimtClient::AlimtClient(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, "alimt"); +} + +AlimtClient::AlimtClient(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, "alimt"); +} + +AlimtClient::~AlimtClient() +{} + +AlimtClient::TranslateECommerceOutcome AlimtClient::translateECommerce(const TranslateECommerceRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return TranslateECommerceOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return TranslateECommerceOutcome(TranslateECommerceResult(outcome.result())); + else + return TranslateECommerceOutcome(outcome.error()); +} + +void AlimtClient::translateECommerceAsync(const TranslateECommerceRequest& request, const TranslateECommerceAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, translateECommerce(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +AlimtClient::TranslateECommerceOutcomeCallable AlimtClient::translateECommerceCallable(const TranslateECommerceRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->translateECommerce(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + +AlimtClient::TranslateGeneralOutcome AlimtClient::translateGeneral(const TranslateGeneralRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return TranslateGeneralOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return TranslateGeneralOutcome(TranslateGeneralResult(outcome.result())); + else + return TranslateGeneralOutcome(outcome.error()); +} + +void AlimtClient::translateGeneralAsync(const TranslateGeneralRequest& request, const TranslateGeneralAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, translateGeneral(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +AlimtClient::TranslateGeneralOutcomeCallable AlimtClient::translateGeneralCallable(const TranslateGeneralRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->translateGeneral(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/alimt/src/model/TranslateECommerceRequest.cc b/alimt/src/model/TranslateECommerceRequest.cc new file mode 100644 index 000000000..4b75aa0e7 --- /dev/null +++ b/alimt/src/model/TranslateECommerceRequest.cc @@ -0,0 +1,71 @@ +/* + * 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::Alimt::Model::TranslateECommerceRequest; + +TranslateECommerceRequest::TranslateECommerceRequest() : + RpcServiceRequest("alimt", "2018-10-12", "TranslateECommerce") +{} + +TranslateECommerceRequest::~TranslateECommerceRequest() +{} + +std::string TranslateECommerceRequest::getSourceLanguage()const +{ + return sourceLanguage_; +} + +void TranslateECommerceRequest::setSourceLanguage(const std::string& sourceLanguage) +{ + sourceLanguage_ = sourceLanguage; + setParameter("SourceLanguage", sourceLanguage); +} + +std::string TranslateECommerceRequest::getSourceText()const +{ + return sourceText_; +} + +void TranslateECommerceRequest::setSourceText(const std::string& sourceText) +{ + sourceText_ = sourceText; + setParameter("SourceText", sourceText); +} + +std::string TranslateECommerceRequest::getFormatType()const +{ + return formatType_; +} + +void TranslateECommerceRequest::setFormatType(const std::string& formatType) +{ + formatType_ = formatType; + setParameter("FormatType", formatType); +} + +std::string TranslateECommerceRequest::getTargetLanguage()const +{ + return targetLanguage_; +} + +void TranslateECommerceRequest::setTargetLanguage(const std::string& targetLanguage) +{ + targetLanguage_ = targetLanguage; + setParameter("TargetLanguage", targetLanguage); +} + diff --git a/alimt/src/model/TranslateECommerceResult.cc b/alimt/src/model/TranslateECommerceResult.cc new file mode 100644 index 000000000..2d302dd20 --- /dev/null +++ b/alimt/src/model/TranslateECommerceResult.cc @@ -0,0 +1,67 @@ +/* + * 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::Alimt; +using namespace AlibabaCloud::Alimt::Model; + +TranslateECommerceResult::TranslateECommerceResult() : + ServiceResult() +{} + +TranslateECommerceResult::TranslateECommerceResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +TranslateECommerceResult::~TranslateECommerceResult() +{} + +void TranslateECommerceResult::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 TranslateECommerceResult::getMessage()const +{ + return message_; +} + +TranslateECommerceResult::Data TranslateECommerceResult::getData()const +{ + return data_; +} + +int TranslateECommerceResult::getCode()const +{ + return code_; +} + diff --git a/alimt/src/model/TranslateGeneralRequest.cc b/alimt/src/model/TranslateGeneralRequest.cc new file mode 100644 index 000000000..b8f87726c --- /dev/null +++ b/alimt/src/model/TranslateGeneralRequest.cc @@ -0,0 +1,71 @@ +/* + * 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::Alimt::Model::TranslateGeneralRequest; + +TranslateGeneralRequest::TranslateGeneralRequest() : + RpcServiceRequest("alimt", "2018-10-12", "TranslateGeneral") +{} + +TranslateGeneralRequest::~TranslateGeneralRequest() +{} + +std::string TranslateGeneralRequest::getSourceLanguage()const +{ + return sourceLanguage_; +} + +void TranslateGeneralRequest::setSourceLanguage(const std::string& sourceLanguage) +{ + sourceLanguage_ = sourceLanguage; + setParameter("SourceLanguage", sourceLanguage); +} + +std::string TranslateGeneralRequest::getSourceText()const +{ + return sourceText_; +} + +void TranslateGeneralRequest::setSourceText(const std::string& sourceText) +{ + sourceText_ = sourceText; + setParameter("SourceText", sourceText); +} + +std::string TranslateGeneralRequest::getFormatType()const +{ + return formatType_; +} + +void TranslateGeneralRequest::setFormatType(const std::string& formatType) +{ + formatType_ = formatType; + setParameter("FormatType", formatType); +} + +std::string TranslateGeneralRequest::getTargetLanguage()const +{ + return targetLanguage_; +} + +void TranslateGeneralRequest::setTargetLanguage(const std::string& targetLanguage) +{ + targetLanguage_ = targetLanguage; + setParameter("TargetLanguage", targetLanguage); +} + diff --git a/alimt/src/model/TranslateGeneralResult.cc b/alimt/src/model/TranslateGeneralResult.cc new file mode 100644 index 000000000..1ac6ba579 --- /dev/null +++ b/alimt/src/model/TranslateGeneralResult.cc @@ -0,0 +1,67 @@ +/* + * 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::Alimt; +using namespace AlibabaCloud::Alimt::Model; + +TranslateGeneralResult::TranslateGeneralResult() : + ServiceResult() +{} + +TranslateGeneralResult::TranslateGeneralResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +TranslateGeneralResult::~TranslateGeneralResult() +{} + +void TranslateGeneralResult::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 TranslateGeneralResult::getMessage()const +{ + return message_; +} + +TranslateGeneralResult::Data TranslateGeneralResult::getData()const +{ + return data_; +} + +int TranslateGeneralResult::getCode()const +{ + return code_; +} +