1 /*
2  * Copyright 2009-2017 Alibaba Cloud All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <alibabacloud/ocr/model/DetectCardScreenshotResult.h>
18 #include <json/json.h>
19 
20 using namespace AlibabaCloud::Ocr;
21 using namespace AlibabaCloud::Ocr::Model;
22 
DetectCardScreenshotResult()23 DetectCardScreenshotResult::DetectCardScreenshotResult() :
24 	ServiceResult()
25 {}
26 
DetectCardScreenshotResult(const std::string & payload)27 DetectCardScreenshotResult::DetectCardScreenshotResult(const std::string &payload) :
28 	ServiceResult()
29 {
30 	parse(payload);
31 }
32 
~DetectCardScreenshotResult()33 DetectCardScreenshotResult::~DetectCardScreenshotResult()
34 {}
35 
parse(const std::string & payload)36 void DetectCardScreenshotResult::parse(const std::string &payload)
37 {
38 	Json::Reader reader;
39 	Json::Value value;
40 	reader.parse(payload, value);
41 	setRequestId(value["RequestId"].asString());
42 	auto dataNode = value["Data"];
43 	if(!dataNode["IsCard"].isNull())
44 		data_.isCard = dataNode["IsCard"].asString() == "true";
45 	if(!dataNode["IsBlur"].isNull())
46 		data_.isBlur = dataNode["IsBlur"].asString() == "true";
47 	auto spoofResultNode = dataNode["SpoofResult"];
48 	if(!spoofResultNode["IsSpoof"].isNull())
49 		data_.spoofResult.isSpoof = spoofResultNode["IsSpoof"].asString() == "true";
50 	auto resultMapNode = spoofResultNode["ResultMap"];
51 	if(!resultMapNode["ScreenScore"].isNull())
52 		data_.spoofResult.resultMap.screenScore = std::stof(resultMapNode["ScreenScore"].asString());
53 	if(!resultMapNode["ScreenThreshold"].isNull())
54 		data_.spoofResult.resultMap.screenThreshold = std::stof(resultMapNode["ScreenThreshold"].asString());
55 
56 }
57 
getData() const58 DetectCardScreenshotResult::Data DetectCardScreenshotResult::getData()const
59 {
60 	return data_;
61 }
62 
63