ModifyScenarioResult.cc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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/ModifyScenarioResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CCC;
  19. using namespace AlibabaCloud::CCC::Model;
  20. ModifyScenarioResult::ModifyScenarioResult() :
  21. ServiceResult()
  22. {}
  23. ModifyScenarioResult::ModifyScenarioResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ModifyScenarioResult::~ModifyScenarioResult()
  29. {}
  30. void ModifyScenarioResult::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 scenarioNode = value["Scenario"];
  37. if(!scenarioNode["ScenarioId"].isNull())
  38. scenario_.scenarioId = scenarioNode["ScenarioId"].asString();
  39. if(!scenarioNode["ScenarioName"].isNull())
  40. scenario_.scenarioName = scenarioNode["ScenarioName"].asString();
  41. if(!scenarioNode["ScenarioDescription"].isNull())
  42. scenario_.scenarioDescription = scenarioNode["ScenarioDescription"].asString();
  43. if(!scenarioNode["Type"].isNull())
  44. scenario_.type = scenarioNode["Type"].asString();
  45. if(!scenarioNode["IsTemplate"].isNull())
  46. scenario_.isTemplate = scenarioNode["IsTemplate"].asString() == "true";
  47. auto allSurveys = value["Surveys"]["Survey"];
  48. for (auto value : allSurveys)
  49. {
  50. Scenario::Survey surveyObject;
  51. if(!value["SurveyId"].isNull())
  52. surveyObject.surveyId = value["SurveyId"].asString();
  53. if(!value["SurveyName"].isNull())
  54. surveyObject.surveyName = value["SurveyName"].asString();
  55. if(!value["SurveyDescription"].isNull())
  56. surveyObject.surveyDescription = value["SurveyDescription"].asString();
  57. if(!value["Role"].isNull())
  58. surveyObject.role = value["Role"].asString();
  59. if(!value["Round"].isNull())
  60. surveyObject.round = std::stoi(value["Round"].asString());
  61. if(!value["BeebotId"].isNull())
  62. surveyObject.beebotId = value["BeebotId"].asString();
  63. auto allIntents = value["Intents"]["IntentNode"];
  64. for (auto value : allIntents)
  65. {
  66. Scenario::Survey::IntentNode intentsObject;
  67. if(!value["NodeId"].isNull())
  68. intentsObject.nodeId = value["NodeId"].asString();
  69. if(!value["IntentId"].isNull())
  70. intentsObject.intentId = value["IntentId"].asString();
  71. surveyObject.intents.push_back(intentsObject);
  72. }
  73. scenario_.surveys.push_back(surveyObject);
  74. }
  75. auto allVariables = value["Variables"]["KeyValuePair"];
  76. for (auto value : allVariables)
  77. {
  78. Scenario::KeyValuePair keyValuePairObject;
  79. if(!value["Key"].isNull())
  80. keyValuePairObject.key = value["Key"].asString();
  81. if(!value["Value"].isNull())
  82. keyValuePairObject.value = value["Value"].asString();
  83. scenario_.variables.push_back(keyValuePairObject);
  84. }
  85. auto strategyNode = scenarioNode["Strategy"];
  86. if(!strategyNode["StrategyId"].isNull())
  87. scenario_.strategy.strategyId = strategyNode["StrategyId"].asString();
  88. if(!strategyNode["StrategyName"].isNull())
  89. scenario_.strategy.strategyName = strategyNode["StrategyName"].asString();
  90. if(!strategyNode["StrategyDescription"].isNull())
  91. scenario_.strategy.strategyDescription = strategyNode["StrategyDescription"].asString();
  92. if(!strategyNode["Type"].isNull())
  93. scenario_.strategy.type = strategyNode["Type"].asString();
  94. if(!strategyNode["StartTime"].isNull())
  95. scenario_.strategy.startTime = std::stol(strategyNode["StartTime"].asString());
  96. if(!strategyNode["EndTime"].isNull())
  97. scenario_.strategy.endTime = std::stol(strategyNode["EndTime"].asString());
  98. if(!strategyNode["RepeatBy"].isNull())
  99. scenario_.strategy.repeatBy = strategyNode["RepeatBy"].asString();
  100. if(!strategyNode["MaxAttemptsPerDay"].isNull())
  101. scenario_.strategy.maxAttemptsPerDay = std::stoi(strategyNode["MaxAttemptsPerDay"].asString());
  102. if(!strategyNode["MinAttemptInterval"].isNull())
  103. scenario_.strategy.minAttemptInterval = std::stoi(strategyNode["MinAttemptInterval"].asString());
  104. if(!strategyNode["Customized"].isNull())
  105. scenario_.strategy.customized = strategyNode["Customized"].asString();
  106. if(!strategyNode["RoutingStrategy"].isNull())
  107. scenario_.strategy.routingStrategy = strategyNode["RoutingStrategy"].asString();
  108. if(!strategyNode["FollowUpStrategy"].isNull())
  109. scenario_.strategy.followUpStrategy = strategyNode["FollowUpStrategy"].asString();
  110. if(!strategyNode["IsTemplate"].isNull())
  111. scenario_.strategy.isTemplate = strategyNode["IsTemplate"].asString() == "true";
  112. auto allWorkingTime = value["WorkingTime"]["TimeFrame"];
  113. for (auto value : allWorkingTime)
  114. {
  115. Scenario::Strategy::TimeFrame timeFrameObject;
  116. if(!value["BeginTime"].isNull())
  117. timeFrameObject.beginTime = value["BeginTime"].asString();
  118. if(!value["EndTime"].isNull())
  119. timeFrameObject.endTime = value["EndTime"].asString();
  120. scenario_.strategy.workingTime.push_back(timeFrameObject);
  121. }
  122. auto allRepeatDays = strategyNode["RepeatDays"]["Integer"];
  123. for (auto value : allRepeatDays)
  124. scenario_.strategy.repeatDays.push_back(value.asString());
  125. if(!value["Success"].isNull())
  126. success_ = value["Success"].asString() == "true";
  127. if(!value["Code"].isNull())
  128. code_ = value["Code"].asString();
  129. if(!value["Message"].isNull())
  130. message_ = value["Message"].asString();
  131. if(!value["HttpStatusCode"].isNull())
  132. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  133. }
  134. std::string ModifyScenarioResult::getMessage()const
  135. {
  136. return message_;
  137. }
  138. int ModifyScenarioResult::getHttpStatusCode()const
  139. {
  140. return httpStatusCode_;
  141. }
  142. std::string ModifyScenarioResult::getCode()const
  143. {
  144. return code_;
  145. }
  146. bool ModifyScenarioResult::getSuccess()const
  147. {
  148. return success_;
  149. }
  150. ModifyScenarioResult::Scenario ModifyScenarioResult::getScenario()const
  151. {
  152. return scenario_;
  153. }