CreateSurveyResult.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #include <alibabacloud/ccc/model/CreateSurveyResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CCC;
  19. using namespace AlibabaCloud::CCC::Model;
  20. CreateSurveyResult::CreateSurveyResult() :
  21. ServiceResult()
  22. {}
  23. CreateSurveyResult::CreateSurveyResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateSurveyResult::~CreateSurveyResult()
  29. {}
  30. void CreateSurveyResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto surveyNode = value["Survey"];
  37. if(!surveyNode["Id"].isNull())
  38. survey_.id = surveyNode["Id"].asString();
  39. if(!surveyNode["ScenarioUuid"].isNull())
  40. survey_.scenarioUuid = surveyNode["ScenarioUuid"].asString();
  41. if(!surveyNode["Name"].isNull())
  42. survey_.name = surveyNode["Name"].asString();
  43. if(!surveyNode["Description"].isNull())
  44. survey_.description = surveyNode["Description"].asString();
  45. if(!surveyNode["Role"].isNull())
  46. survey_.role = surveyNode["Role"].asString();
  47. if(!surveyNode["Round"].isNull())
  48. survey_.round = std::stoi(surveyNode["Round"].asString());
  49. if(!surveyNode["HotWords"].isNull())
  50. survey_.hotWords = surveyNode["HotWords"].asString();
  51. if(!surveyNode["SpeechOptimizationParam"].isNull())
  52. survey_.speechOptimizationParam = surveyNode["SpeechOptimizationParam"].asString();
  53. if(!surveyNode["GlobalQuestions"].isNull())
  54. survey_.globalQuestions = surveyNode["GlobalQuestions"].asString();
  55. auto flowNode = surveyNode["Flow"];
  56. if(!flowNode["FlowId"].isNull())
  57. survey_.flow.flowId = flowNode["FlowId"].asString();
  58. if(!flowNode["IsPublished"].isNull())
  59. survey_.flow.isPublished = flowNode["IsPublished"].asString() == "true";
  60. if(!flowNode["FlowJson"].isNull())
  61. survey_.flow.flowJson = flowNode["FlowJson"].asString();
  62. auto asrCustomModelNode = surveyNode["AsrCustomModel"];
  63. if(!asrCustomModelNode["Corpora"].isNull())
  64. survey_.asrCustomModel.corpora = asrCustomModelNode["Corpora"].asString();
  65. if(!asrCustomModelNode["CustomModelStatus"].isNull())
  66. survey_.asrCustomModel.customModelStatus = std::stoi(asrCustomModelNode["CustomModelStatus"].asString());
  67. if(!value["Success"].isNull())
  68. success_ = value["Success"].asString() == "true";
  69. if(!value["Code"].isNull())
  70. code_ = value["Code"].asString();
  71. if(!value["Message"].isNull())
  72. message_ = value["Message"].asString();
  73. if(!value["HttpStatusCode"].isNull())
  74. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  75. }
  76. CreateSurveyResult::Survey CreateSurveyResult::getSurvey()const
  77. {
  78. return survey_;
  79. }
  80. std::string CreateSurveyResult::getMessage()const
  81. {
  82. return message_;
  83. }
  84. int CreateSurveyResult::getHttpStatusCode()const
  85. {
  86. return httpStatusCode_;
  87. }
  88. std::string CreateSurveyResult::getCode()const
  89. {
  90. return code_;
  91. }
  92. bool CreateSurveyResult::getSuccess()const
  93. {
  94. return success_;
  95. }