DialogueResult.cc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/outboundbot/model/DialogueResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::OutboundBot;
  19. using namespace AlibabaCloud::OutboundBot::Model;
  20. DialogueResult::DialogueResult() :
  21. ServiceResult()
  22. {}
  23. DialogueResult::DialogueResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DialogueResult::~DialogueResult()
  29. {}
  30. void DialogueResult::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 feedbackNode = value["Feedback"];
  37. if(!feedbackNode["Action"].isNull())
  38. feedback_.action = feedbackNode["Action"].asString();
  39. if(!feedbackNode["ActionParams"].isNull())
  40. feedback_.actionParams = feedbackNode["ActionParams"].asString();
  41. if(!feedbackNode["Content"].isNull())
  42. feedback_.content = feedbackNode["Content"].asString();
  43. if(!feedbackNode["Interruptible"].isNull())
  44. feedback_.interruptible = feedbackNode["Interruptible"].asString() == "true";
  45. if(!feedbackNode["ContentParams"].isNull())
  46. feedback_.contentParams = feedbackNode["ContentParams"].asString();
  47. if(!value["HttpStatusCode"].isNull())
  48. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  49. if(!value["Code"].isNull())
  50. code_ = value["Code"].asString();
  51. if(!value["Message"].isNull())
  52. message_ = value["Message"].asString();
  53. if(!value["Success"].isNull())
  54. success_ = value["Success"].asString() == "true";
  55. }
  56. std::string DialogueResult::getMessage()const
  57. {
  58. return message_;
  59. }
  60. DialogueResult::Feedback DialogueResult::getFeedback()const
  61. {
  62. return feedback_;
  63. }
  64. int DialogueResult::getHttpStatusCode()const
  65. {
  66. return httpStatusCode_;
  67. }
  68. std::string DialogueResult::getCode()const
  69. {
  70. return code_;
  71. }
  72. bool DialogueResult::getSuccess()const
  73. {
  74. return success_;
  75. }