ListScriptsResult.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/ListScriptsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::OutboundBot;
  19. using namespace AlibabaCloud::OutboundBot::Model;
  20. ListScriptsResult::ListScriptsResult() :
  21. ServiceResult()
  22. {}
  23. ListScriptsResult::ListScriptsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListScriptsResult::~ListScriptsResult()
  29. {}
  30. void ListScriptsResult::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 scriptsNode = value["Scripts"];
  37. if(!scriptsNode["PageNumber"].isNull())
  38. scripts_.pageNumber = std::stoi(scriptsNode["PageNumber"].asString());
  39. if(!scriptsNode["PageSize"].isNull())
  40. scripts_.pageSize = std::stoi(scriptsNode["PageSize"].asString());
  41. if(!scriptsNode["TotalCount"].isNull())
  42. scripts_.totalCount = std::stoi(scriptsNode["TotalCount"].asString());
  43. auto allListNode = scriptsNode["List"]["Script"];
  44. for (auto scriptsNodeListScript : allListNode)
  45. {
  46. Scripts::Script scriptObject;
  47. if(!scriptsNodeListScript["DebugStatus"].isNull())
  48. scriptObject.debugStatus = scriptsNodeListScript["DebugStatus"].asString();
  49. if(!scriptsNodeListScript["FailReason"].isNull())
  50. scriptObject.failReason = scriptsNodeListScript["FailReason"].asString();
  51. if(!scriptsNodeListScript["Industry"].isNull())
  52. scriptObject.industry = scriptsNodeListScript["Industry"].asString();
  53. if(!scriptsNodeListScript["IsDebugDrafted"].isNull())
  54. scriptObject.isDebugDrafted = scriptsNodeListScript["IsDebugDrafted"].asString() == "true";
  55. if(!scriptsNodeListScript["IsDrafted"].isNull())
  56. scriptObject.isDrafted = scriptsNodeListScript["IsDrafted"].asString() == "true";
  57. if(!scriptsNodeListScript["Scene"].isNull())
  58. scriptObject.scene = scriptsNodeListScript["Scene"].asString();
  59. if(!scriptsNodeListScript["ScriptDescription"].isNull())
  60. scriptObject.scriptDescription = scriptsNodeListScript["ScriptDescription"].asString();
  61. if(!scriptsNodeListScript["ScriptId"].isNull())
  62. scriptObject.scriptId = scriptsNodeListScript["ScriptId"].asString();
  63. if(!scriptsNodeListScript["ScriptName"].isNull())
  64. scriptObject.scriptName = scriptsNodeListScript["ScriptName"].asString();
  65. if(!scriptsNodeListScript["Status"].isNull())
  66. scriptObject.status = scriptsNodeListScript["Status"].asString();
  67. if(!scriptsNodeListScript["UpdateTime"].isNull())
  68. scriptObject.updateTime = std::stol(scriptsNodeListScript["UpdateTime"].asString());
  69. if(!scriptsNodeListScript["RejectReason"].isNull())
  70. scriptObject.rejectReason = scriptsNodeListScript["RejectReason"].asString();
  71. scripts_.list.push_back(scriptObject);
  72. }
  73. if(!value["Code"].isNull())
  74. code_ = value["Code"].asString();
  75. if(!value["HttpStatusCode"].isNull())
  76. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  77. if(!value["Message"].isNull())
  78. message_ = value["Message"].asString();
  79. if(!value["Success"].isNull())
  80. success_ = value["Success"].asString() == "true";
  81. }
  82. ListScriptsResult::Scripts ListScriptsResult::getScripts()const
  83. {
  84. return scripts_;
  85. }
  86. std::string ListScriptsResult::getMessage()const
  87. {
  88. return message_;
  89. }
  90. int ListScriptsResult::getHttpStatusCode()const
  91. {
  92. return httpStatusCode_;
  93. }
  94. std::string ListScriptsResult::getCode()const
  95. {
  96. return code_;
  97. }
  98. bool ListScriptsResult::getSuccess()const
  99. {
  100. return success_;
  101. }