Generated 2023-03-05 for captcha.
This commit is contained in:
90
captcha/CMakeLists.txt
Normal file
90
captcha/CMakeLists.txt
Normal file
@@ -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(captcha_public_header
|
||||
include/alibabacloud/captcha/CaptchaClient.h
|
||||
include/alibabacloud/captcha/CaptchaExport.h )
|
||||
|
||||
set(captcha_public_header_model
|
||||
include/alibabacloud/captcha/model/VerifyCaptchaRequest.h
|
||||
include/alibabacloud/captcha/model/VerifyCaptchaResult.h
|
||||
include/alibabacloud/captcha/model/VerifyIntelligentCaptchaRequest.h
|
||||
include/alibabacloud/captcha/model/VerifyIntelligentCaptchaResult.h )
|
||||
|
||||
set(captcha_src
|
||||
src/CaptchaClient.cc
|
||||
src/model/VerifyCaptchaRequest.cc
|
||||
src/model/VerifyCaptchaResult.cc
|
||||
src/model/VerifyIntelligentCaptchaRequest.cc
|
||||
src/model/VerifyIntelligentCaptchaResult.cc )
|
||||
|
||||
add_library(captcha ${LIB_TYPE}
|
||||
${captcha_public_header}
|
||||
${captcha_public_header_model}
|
||||
${captcha_src})
|
||||
|
||||
set_target_properties(captcha
|
||||
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}captcha
|
||||
)
|
||||
|
||||
if(${LIB_TYPE} STREQUAL "SHARED")
|
||||
set_target_properties(captcha
|
||||
PROPERTIES
|
||||
DEFINE_SYMBOL ALIBABACLOUD_CAPTCHA_LIBRARY)
|
||||
endif()
|
||||
|
||||
target_include_directories(captcha
|
||||
PRIVATE include
|
||||
${CMAKE_SOURCE_DIR}/core/include
|
||||
)
|
||||
target_link_libraries(captcha
|
||||
core)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
ExternalProject_Get_Property(jsoncpp INSTALL_DIR)
|
||||
set(jsoncpp_install_dir ${INSTALL_DIR})
|
||||
add_dependencies(captcha
|
||||
jsoncpp)
|
||||
target_include_directories(captcha
|
||||
PRIVATE ${jsoncpp_install_dir}/include)
|
||||
target_link_libraries(captcha
|
||||
${jsoncpp_install_dir}/lib/jsoncpp.lib)
|
||||
set_target_properties(captcha
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS "/bigobj")
|
||||
else()
|
||||
target_include_directories(captcha
|
||||
PRIVATE /usr/include/jsoncpp)
|
||||
target_link_libraries(captcha
|
||||
jsoncpp)
|
||||
endif()
|
||||
|
||||
install(FILES ${captcha_public_header}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/captcha)
|
||||
install(FILES ${captcha_public_header_model}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/captcha/model)
|
||||
install(TARGETS captcha
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
62
captcha/include/alibabacloud/captcha/CaptchaClient.h
Normal file
62
captcha/include/alibabacloud/captcha/CaptchaClient.h
Normal file
@@ -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_CAPTCHA_CAPTCHACLIENT_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_CAPTCHACLIENT_H_
|
||||
|
||||
#include <future>
|
||||
#include <alibabacloud/core/AsyncCallerContext.h>
|
||||
#include <alibabacloud/core/EndpointProvider.h>
|
||||
#include <alibabacloud/core/RpcServiceClient.h>
|
||||
#include "CaptchaExport.h"
|
||||
#include "model/VerifyCaptchaRequest.h"
|
||||
#include "model/VerifyCaptchaResult.h"
|
||||
#include "model/VerifyIntelligentCaptchaRequest.h"
|
||||
#include "model/VerifyIntelligentCaptchaResult.h"
|
||||
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Captcha
|
||||
{
|
||||
class ALIBABACLOUD_CAPTCHA_EXPORT CaptchaClient : public RpcServiceClient
|
||||
{
|
||||
public:
|
||||
typedef Outcome<Error, Model::VerifyCaptchaResult> VerifyCaptchaOutcome;
|
||||
typedef std::future<VerifyCaptchaOutcome> VerifyCaptchaOutcomeCallable;
|
||||
typedef std::function<void(const CaptchaClient*, const Model::VerifyCaptchaRequest&, const VerifyCaptchaOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> VerifyCaptchaAsyncHandler;
|
||||
typedef Outcome<Error, Model::VerifyIntelligentCaptchaResult> VerifyIntelligentCaptchaOutcome;
|
||||
typedef std::future<VerifyIntelligentCaptchaOutcome> VerifyIntelligentCaptchaOutcomeCallable;
|
||||
typedef std::function<void(const CaptchaClient*, const Model::VerifyIntelligentCaptchaRequest&, const VerifyIntelligentCaptchaOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> VerifyIntelligentCaptchaAsyncHandler;
|
||||
|
||||
CaptchaClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
CaptchaClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
CaptchaClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
|
||||
~CaptchaClient();
|
||||
VerifyCaptchaOutcome verifyCaptcha(const Model::VerifyCaptchaRequest &request)const;
|
||||
void verifyCaptchaAsync(const Model::VerifyCaptchaRequest& request, const VerifyCaptchaAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
VerifyCaptchaOutcomeCallable verifyCaptchaCallable(const Model::VerifyCaptchaRequest& request) const;
|
||||
VerifyIntelligentCaptchaOutcome verifyIntelligentCaptcha(const Model::VerifyIntelligentCaptchaRequest &request)const;
|
||||
void verifyIntelligentCaptchaAsync(const Model::VerifyIntelligentCaptchaRequest& request, const VerifyIntelligentCaptchaAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
VerifyIntelligentCaptchaOutcomeCallable verifyIntelligentCaptchaCallable(const Model::VerifyIntelligentCaptchaRequest& request) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_CAPTCHACLIENT_H_
|
||||
32
captcha/include/alibabacloud/captcha/CaptchaExport.h
Normal file
32
captcha/include/alibabacloud/captcha/CaptchaExport.h
Normal file
@@ -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_CAPTCHA_CAPTCHAEXPORT_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_CAPTCHAEXPORT_H_
|
||||
|
||||
#include <alibabacloud/core/Global.h>
|
||||
|
||||
#if defined(ALIBABACLOUD_SHARED)
|
||||
# if defined(ALIBABACLOUD_CAPTCHA_LIBRARY)
|
||||
# define ALIBABACLOUD_CAPTCHA_EXPORT ALIBABACLOUD_DECL_EXPORT
|
||||
# else
|
||||
# define ALIBABACLOUD_CAPTCHA_EXPORT ALIBABACLOUD_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define ALIBABACLOUD_CAPTCHA_EXPORT
|
||||
#endif
|
||||
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_CAPTCHAEXPORT_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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_CAPTCHA_MODEL_VERIFYCAPTCHAREQUEST_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_MODEL_VERIFYCAPTCHAREQUEST_H_
|
||||
|
||||
#include <alibabacloud/captcha/CaptchaExport.h>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace AlibabaCloud {
|
||||
namespace Captcha {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CAPTCHA_EXPORT VerifyCaptchaRequest : public RpcServiceRequest {
|
||||
public:
|
||||
VerifyCaptchaRequest();
|
||||
~VerifyCaptchaRequest();
|
||||
std::string getCaptchaVerifyParam() const;
|
||||
void setCaptchaVerifyParam(const std::string &captchaVerifyParam);
|
||||
|
||||
private:
|
||||
std::string captchaVerifyParam_;
|
||||
};
|
||||
} // namespace Model
|
||||
} // namespace Captcha
|
||||
} // namespace AlibabaCloud
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_MODEL_VERIFYCAPTCHAREQUEST_H_
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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_CAPTCHA_MODEL_VERIFYCAPTCHARESULT_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_MODEL_VERIFYCAPTCHARESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/captcha/CaptchaExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Captcha
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CAPTCHA_EXPORT VerifyCaptchaResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Result
|
||||
{
|
||||
bool verifyResult;
|
||||
};
|
||||
|
||||
|
||||
VerifyCaptchaResult();
|
||||
explicit VerifyCaptchaResult(const std::string &payload);
|
||||
~VerifyCaptchaResult();
|
||||
std::string getMessage()const;
|
||||
std::string getCode()const;
|
||||
bool getSuccess()const;
|
||||
Result getResult()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string message_;
|
||||
std::string code_;
|
||||
bool success_;
|
||||
Result result_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_MODEL_VERIFYCAPTCHARESULT_H_
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHAREQUEST_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHAREQUEST_H_
|
||||
|
||||
#include <alibabacloud/captcha/CaptchaExport.h>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace AlibabaCloud {
|
||||
namespace Captcha {
|
||||
namespace Model {
|
||||
class ALIBABACLOUD_CAPTCHA_EXPORT VerifyIntelligentCaptchaRequest : public RpcServiceRequest {
|
||||
public:
|
||||
VerifyIntelligentCaptchaRequest();
|
||||
~VerifyIntelligentCaptchaRequest();
|
||||
std::string getCaptchaVerifyParam() const;
|
||||
void setCaptchaVerifyParam(const std::string &captchaVerifyParam);
|
||||
std::string getSceneId() const;
|
||||
void setSceneId(const std::string &sceneId);
|
||||
|
||||
private:
|
||||
std::string captchaVerifyParam_;
|
||||
std::string sceneId_;
|
||||
};
|
||||
} // namespace Model
|
||||
} // namespace Captcha
|
||||
} // namespace AlibabaCloud
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHAREQUEST_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_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHARESULT_H_
|
||||
#define ALIBABACLOUD_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHARESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/captcha/CaptchaExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Captcha
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_CAPTCHA_EXPORT VerifyIntelligentCaptchaResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Result
|
||||
{
|
||||
std::string verifyCode;
|
||||
bool verifyResult;
|
||||
};
|
||||
|
||||
|
||||
VerifyIntelligentCaptchaResult();
|
||||
explicit VerifyIntelligentCaptchaResult(const std::string &payload);
|
||||
~VerifyIntelligentCaptchaResult();
|
||||
std::string getMessage()const;
|
||||
std::string getCode()const;
|
||||
bool getSuccess()const;
|
||||
Result getResult()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string message_;
|
||||
std::string code_;
|
||||
bool success_;
|
||||
Result result_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_CAPTCHA_MODEL_VERIFYINTELLIGENTCAPTCHARESULT_H_
|
||||
125
captcha/src/CaptchaClient.cc
Normal file
125
captcha/src/CaptchaClient.cc
Normal file
@@ -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 <alibabacloud/captcha/CaptchaClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::Captcha;
|
||||
using namespace AlibabaCloud::Captcha::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string SERVICE_NAME = "captcha";
|
||||
}
|
||||
|
||||
CaptchaClient::CaptchaClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
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, "");
|
||||
}
|
||||
|
||||
CaptchaClient::CaptchaClient(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, "");
|
||||
}
|
||||
|
||||
CaptchaClient::CaptchaClient(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, "");
|
||||
}
|
||||
|
||||
CaptchaClient::~CaptchaClient()
|
||||
{}
|
||||
|
||||
CaptchaClient::VerifyCaptchaOutcome CaptchaClient::verifyCaptcha(const VerifyCaptchaRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return VerifyCaptchaOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return VerifyCaptchaOutcome(VerifyCaptchaResult(outcome.result()));
|
||||
else
|
||||
return VerifyCaptchaOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void CaptchaClient::verifyCaptchaAsync(const VerifyCaptchaRequest& request, const VerifyCaptchaAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, verifyCaptcha(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
CaptchaClient::VerifyCaptchaOutcomeCallable CaptchaClient::verifyCaptchaCallable(const VerifyCaptchaRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<VerifyCaptchaOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->verifyCaptcha(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
CaptchaClient::VerifyIntelligentCaptchaOutcome CaptchaClient::verifyIntelligentCaptcha(const VerifyIntelligentCaptchaRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return VerifyIntelligentCaptchaOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return VerifyIntelligentCaptchaOutcome(VerifyIntelligentCaptchaResult(outcome.result()));
|
||||
else
|
||||
return VerifyIntelligentCaptchaOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void CaptchaClient::verifyIntelligentCaptchaAsync(const VerifyIntelligentCaptchaRequest& request, const VerifyIntelligentCaptchaAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, verifyIntelligentCaptcha(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
CaptchaClient::VerifyIntelligentCaptchaOutcomeCallable CaptchaClient::verifyIntelligentCaptchaCallable(const VerifyIntelligentCaptchaRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<VerifyIntelligentCaptchaOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->verifyIntelligentCaptcha(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
36
captcha/src/model/VerifyCaptchaRequest.cc
Normal file
36
captcha/src/model/VerifyCaptchaRequest.cc
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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/captcha/model/VerifyCaptchaRequest.h>
|
||||
|
||||
using AlibabaCloud::Captcha::Model::VerifyCaptchaRequest;
|
||||
|
||||
VerifyCaptchaRequest::VerifyCaptchaRequest()
|
||||
: RpcServiceRequest("captcha", "2023-03-05", "VerifyCaptcha") {
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
VerifyCaptchaRequest::~VerifyCaptchaRequest() {}
|
||||
|
||||
std::string VerifyCaptchaRequest::getCaptchaVerifyParam() const {
|
||||
return captchaVerifyParam_;
|
||||
}
|
||||
|
||||
void VerifyCaptchaRequest::setCaptchaVerifyParam(const std::string &captchaVerifyParam) {
|
||||
captchaVerifyParam_ = captchaVerifyParam;
|
||||
setParameter(std::string("CaptchaVerifyParam"), captchaVerifyParam);
|
||||
}
|
||||
|
||||
73
captcha/src/model/VerifyCaptchaResult.cc
Normal file
73
captcha/src/model/VerifyCaptchaResult.cc
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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/captcha/model/VerifyCaptchaResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Captcha;
|
||||
using namespace AlibabaCloud::Captcha::Model;
|
||||
|
||||
VerifyCaptchaResult::VerifyCaptchaResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
VerifyCaptchaResult::VerifyCaptchaResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
VerifyCaptchaResult::~VerifyCaptchaResult()
|
||||
{}
|
||||
|
||||
void VerifyCaptchaResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto resultNode = value["Result"];
|
||||
if(!resultNode["VerifyResult"].isNull())
|
||||
result_.verifyResult = resultNode["VerifyResult"].asString() == "true";
|
||||
if(!value["Success"].isNull())
|
||||
success_ = value["Success"].asString() == "true";
|
||||
if(!value["Code"].isNull())
|
||||
code_ = value["Code"].asString();
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string VerifyCaptchaResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
std::string VerifyCaptchaResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
bool VerifyCaptchaResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
VerifyCaptchaResult::Result VerifyCaptchaResult::getResult()const
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
|
||||
45
captcha/src/model/VerifyIntelligentCaptchaRequest.cc
Normal file
45
captcha/src/model/VerifyIntelligentCaptchaRequest.cc
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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/captcha/model/VerifyIntelligentCaptchaRequest.h>
|
||||
|
||||
using AlibabaCloud::Captcha::Model::VerifyIntelligentCaptchaRequest;
|
||||
|
||||
VerifyIntelligentCaptchaRequest::VerifyIntelligentCaptchaRequest()
|
||||
: RpcServiceRequest("captcha", "2023-03-05", "VerifyIntelligentCaptcha") {
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
VerifyIntelligentCaptchaRequest::~VerifyIntelligentCaptchaRequest() {}
|
||||
|
||||
std::string VerifyIntelligentCaptchaRequest::getCaptchaVerifyParam() const {
|
||||
return captchaVerifyParam_;
|
||||
}
|
||||
|
||||
void VerifyIntelligentCaptchaRequest::setCaptchaVerifyParam(const std::string &captchaVerifyParam) {
|
||||
captchaVerifyParam_ = captchaVerifyParam;
|
||||
setBodyParameter(std::string("CaptchaVerifyParam"), captchaVerifyParam);
|
||||
}
|
||||
|
||||
std::string VerifyIntelligentCaptchaRequest::getSceneId() const {
|
||||
return sceneId_;
|
||||
}
|
||||
|
||||
void VerifyIntelligentCaptchaRequest::setSceneId(const std::string &sceneId) {
|
||||
sceneId_ = sceneId;
|
||||
setBodyParameter(std::string("SceneId"), sceneId);
|
||||
}
|
||||
|
||||
75
captcha/src/model/VerifyIntelligentCaptchaResult.cc
Normal file
75
captcha/src/model/VerifyIntelligentCaptchaResult.cc
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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/captcha/model/VerifyIntelligentCaptchaResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Captcha;
|
||||
using namespace AlibabaCloud::Captcha::Model;
|
||||
|
||||
VerifyIntelligentCaptchaResult::VerifyIntelligentCaptchaResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
VerifyIntelligentCaptchaResult::VerifyIntelligentCaptchaResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
VerifyIntelligentCaptchaResult::~VerifyIntelligentCaptchaResult()
|
||||
{}
|
||||
|
||||
void VerifyIntelligentCaptchaResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto resultNode = value["Result"];
|
||||
if(!resultNode["VerifyResult"].isNull())
|
||||
result_.verifyResult = resultNode["VerifyResult"].asString() == "true";
|
||||
if(!resultNode["VerifyCode"].isNull())
|
||||
result_.verifyCode = resultNode["VerifyCode"].asString();
|
||||
if(!value["Success"].isNull())
|
||||
success_ = value["Success"].asString() == "true";
|
||||
if(!value["Code"].isNull())
|
||||
code_ = value["Code"].asString();
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string VerifyIntelligentCaptchaResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
std::string VerifyIntelligentCaptchaResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
bool VerifyIntelligentCaptchaResult::getSuccess()const
|
||||
{
|
||||
return success_;
|
||||
}
|
||||
|
||||
VerifyIntelligentCaptchaResult::Result VerifyIntelligentCaptchaResult::getResult()const
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user