ListGlobalQuestionsResult.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/ListGlobalQuestionsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::OutboundBot;
  19. using namespace AlibabaCloud::OutboundBot::Model;
  20. ListGlobalQuestionsResult::ListGlobalQuestionsResult() :
  21. ServiceResult()
  22. {}
  23. ListGlobalQuestionsResult::ListGlobalQuestionsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListGlobalQuestionsResult::~ListGlobalQuestionsResult()
  29. {}
  30. void ListGlobalQuestionsResult::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 globalQuestionsNode = value["GlobalQuestions"];
  37. if(!globalQuestionsNode["PageNumber"].isNull())
  38. globalQuestions_.pageNumber = std::stoi(globalQuestionsNode["PageNumber"].asString());
  39. if(!globalQuestionsNode["PageSize"].isNull())
  40. globalQuestions_.pageSize = std::stoi(globalQuestionsNode["PageSize"].asString());
  41. if(!globalQuestionsNode["TotalCount"].isNull())
  42. globalQuestions_.totalCount = std::stoi(globalQuestionsNode["TotalCount"].asString());
  43. auto allListNode = globalQuestionsNode["List"]["GlobalQuestion"];
  44. for (auto globalQuestionsNodeListGlobalQuestion : allListNode)
  45. {
  46. GlobalQuestions::GlobalQuestion globalQuestionObject;
  47. if(!globalQuestionsNodeListGlobalQuestion["Answers"].isNull())
  48. globalQuestionObject.answers = globalQuestionsNodeListGlobalQuestion["Answers"].asString();
  49. if(!globalQuestionsNodeListGlobalQuestion["GlobalQuestionId"].isNull())
  50. globalQuestionObject.globalQuestionId = globalQuestionsNodeListGlobalQuestion["GlobalQuestionId"].asString();
  51. if(!globalQuestionsNodeListGlobalQuestion["GlobalQuestionName"].isNull())
  52. globalQuestionObject.globalQuestionName = globalQuestionsNodeListGlobalQuestion["GlobalQuestionName"].asString();
  53. if(!globalQuestionsNodeListGlobalQuestion["GlobalQuestionType"].isNull())
  54. globalQuestionObject.globalQuestionType = globalQuestionsNodeListGlobalQuestion["GlobalQuestionType"].asString();
  55. if(!globalQuestionsNodeListGlobalQuestion["Questions"].isNull())
  56. globalQuestionObject.questions = globalQuestionsNodeListGlobalQuestion["Questions"].asString();
  57. if(!globalQuestionsNodeListGlobalQuestion["ScriptId"].isNull())
  58. globalQuestionObject.scriptId = globalQuestionsNodeListGlobalQuestion["ScriptId"].asString();
  59. globalQuestions_.list.push_back(globalQuestionObject);
  60. }
  61. if(!value["Code"].isNull())
  62. code_ = value["Code"].asString();
  63. if(!value["HttpStatusCode"].isNull())
  64. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  65. if(!value["Message"].isNull())
  66. message_ = value["Message"].asString();
  67. if(!value["Success"].isNull())
  68. success_ = value["Success"].asString() == "true";
  69. }
  70. std::string ListGlobalQuestionsResult::getMessage()const
  71. {
  72. return message_;
  73. }
  74. int ListGlobalQuestionsResult::getHttpStatusCode()const
  75. {
  76. return httpStatusCode_;
  77. }
  78. ListGlobalQuestionsResult::GlobalQuestions ListGlobalQuestionsResult::getGlobalQuestions()const
  79. {
  80. return globalQuestions_;
  81. }
  82. std::string ListGlobalQuestionsResult::getCode()const
  83. {
  84. return code_;
  85. }
  86. bool ListGlobalQuestionsResult::getSuccess()const
  87. {
  88. return success_;
  89. }