CreateMergeRequestCommentResult.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/codeup/model/CreateMergeRequestCommentResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Codeup;
  19. using namespace AlibabaCloud::Codeup::Model;
  20. CreateMergeRequestCommentResult::CreateMergeRequestCommentResult() :
  21. ServiceResult()
  22. {}
  23. CreateMergeRequestCommentResult::CreateMergeRequestCommentResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateMergeRequestCommentResult::~CreateMergeRequestCommentResult()
  29. {}
  30. void CreateMergeRequestCommentResult::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 resultNode = value["Result"];
  37. if(!resultNode["Id"].isNull())
  38. result_.id = std::stol(resultNode["Id"].asString());
  39. if(!resultNode["Note"].isNull())
  40. result_.note = resultNode["Note"].asString();
  41. if(!resultNode["CreatedAt"].isNull())
  42. result_.createdAt = resultNode["CreatedAt"].asString();
  43. if(!resultNode["UpdatedAt"].isNull())
  44. result_.updatedAt = resultNode["UpdatedAt"].asString();
  45. if(!resultNode["ProjectId"].isNull())
  46. result_.projectId = std::stol(resultNode["ProjectId"].asString());
  47. if(!resultNode["IsDraft"].isNull())
  48. result_.isDraft = resultNode["IsDraft"].asString() == "true";
  49. if(!resultNode["ParentNoteId"].isNull())
  50. result_.parentNoteId = std::stol(resultNode["ParentNoteId"].asString());
  51. if(!resultNode["Line"].isNull())
  52. result_.line = std::stol(resultNode["Line"].asString());
  53. if(!resultNode["Side"].isNull())
  54. result_.side = resultNode["Side"].asString();
  55. if(!resultNode["Path"].isNull())
  56. result_.path = resultNode["Path"].asString();
  57. if(!resultNode["RangeContext"].isNull())
  58. result_.rangeContext = resultNode["RangeContext"].asString();
  59. if(!resultNode["OutDated"].isNull())
  60. result_.outDated = resultNode["OutDated"].asString() == "true";
  61. if(!resultNode["Closed"].isNull())
  62. result_.closed = std::stoi(resultNode["Closed"].asString());
  63. auto authorNode = resultNode["Author"];
  64. if(!authorNode["Id"].isNull())
  65. result_.author.id = std::stol(authorNode["Id"].asString());
  66. if(!authorNode["AvatarUrl"].isNull())
  67. result_.author.avatarUrl = authorNode["AvatarUrl"].asString();
  68. if(!authorNode["ExternUserId"].isNull())
  69. result_.author.externUserId = authorNode["ExternUserId"].asString();
  70. if(!authorNode["Name"].isNull())
  71. result_.author.name = authorNode["Name"].asString();
  72. if(!authorNode["Email"].isNull())
  73. result_.author.email = authorNode["Email"].asString();
  74. if(!value["ErrorCode"].isNull())
  75. errorCode_ = value["ErrorCode"].asString();
  76. if(!value["ErrorMessage"].isNull())
  77. errorMessage_ = value["ErrorMessage"].asString();
  78. if(!value["Success"].isNull())
  79. success_ = value["Success"].asString() == "true";
  80. }
  81. std::string CreateMergeRequestCommentResult::getErrorCode()const
  82. {
  83. return errorCode_;
  84. }
  85. std::string CreateMergeRequestCommentResult::getErrorMessage()const
  86. {
  87. return errorMessage_;
  88. }
  89. bool CreateMergeRequestCommentResult::getSuccess()const
  90. {
  91. return success_;
  92. }
  93. CreateMergeRequestCommentResult::Result CreateMergeRequestCommentResult::getResult()const
  94. {
  95. return result_;
  96. }