ListTicketsResult.cc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/workorder/model/ListTicketsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Workorder;
  19. using namespace AlibabaCloud::Workorder::Model;
  20. ListTicketsResult::ListTicketsResult() :
  21. ServiceResult()
  22. {}
  23. ListTicketsResult::ListTicketsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListTicketsResult::~ListTicketsResult()
  29. {}
  30. void ListTicketsResult::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 dataNode = value["Data"];
  37. if(!dataNode["Total"].isNull())
  38. data_.total = std::stoi(dataNode["Total"].asString());
  39. if(!dataNode["PageSize"].isNull())
  40. data_.pageSize = std::stoi(dataNode["PageSize"].asString());
  41. if(!dataNode["CurrentPage"].isNull())
  42. data_.currentPage = std::stoi(dataNode["CurrentPage"].asString());
  43. auto allListNode = dataNode["List"]["ListItem"];
  44. for (auto dataNodeListListItem : allListNode)
  45. {
  46. Data::ListItem listItemObject;
  47. if(!dataNodeListListItem["AddTime"].isNull())
  48. listItemObject.addTime = std::stoi(dataNodeListListItem["AddTime"].asString());
  49. if(!dataNodeListListItem["TicketStatus"].isNull())
  50. listItemObject.ticketStatus = dataNodeListListItem["TicketStatus"].asString();
  51. if(!dataNodeListListItem["CreatorId"].isNull())
  52. listItemObject.creatorId = dataNodeListListItem["CreatorId"].asString();
  53. if(!dataNodeListListItem["Id"].isNull())
  54. listItemObject.id = dataNodeListListItem["Id"].asString();
  55. if(!dataNodeListListItem["Title"].isNull())
  56. listItemObject.title = dataNodeListListItem["Title"].asString();
  57. data_.list.push_back(listItemObject);
  58. }
  59. if(!value["Code"].isNull())
  60. code_ = std::stoi(value["Code"].asString());
  61. if(!value["Success"].isNull())
  62. success_ = value["Success"].asString() == "true";
  63. if(!value["Message"].isNull())
  64. message_ = value["Message"].asString();
  65. }
  66. std::string ListTicketsResult::getMessage()const
  67. {
  68. return message_;
  69. }
  70. ListTicketsResult::Data ListTicketsResult::getData()const
  71. {
  72. return data_;
  73. }
  74. int ListTicketsResult::getCode()const
  75. {
  76. return code_;
  77. }
  78. bool ListTicketsResult::getSuccess()const
  79. {
  80. return success_;
  81. }