ListRepositoryWebhookResult.cc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/ListRepositoryWebhookResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Codeup;
  19. using namespace AlibabaCloud::Codeup::Model;
  20. ListRepositoryWebhookResult::ListRepositoryWebhookResult() :
  21. ServiceResult()
  22. {}
  23. ListRepositoryWebhookResult::ListRepositoryWebhookResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListRepositoryWebhookResult::~ListRepositoryWebhookResult()
  29. {}
  30. void ListRepositoryWebhookResult::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 allResultNode = value["Result"]["ResultItem"];
  37. for (auto valueResultResultItem : allResultNode)
  38. {
  39. ResultItem resultObject;
  40. if(!valueResultResultItem["Id"].isNull())
  41. resultObject.id = std::stol(valueResultResultItem["Id"].asString());
  42. if(!valueResultResultItem["Url"].isNull())
  43. resultObject.url = valueResultResultItem["Url"].asString();
  44. if(!valueResultResultItem["CreatedAt"].isNull())
  45. resultObject.createdAt = valueResultResultItem["CreatedAt"].asString();
  46. if(!valueResultResultItem["ProjectId"].isNull())
  47. resultObject.projectId = std::stol(valueResultResultItem["ProjectId"].asString());
  48. if(!valueResultResultItem["PushEvents"].isNull())
  49. resultObject.pushEvents = valueResultResultItem["PushEvents"].asString() == "true";
  50. if(!valueResultResultItem["MergeRequestsEvents"].isNull())
  51. resultObject.mergeRequestsEvents = valueResultResultItem["MergeRequestsEvents"].asString() == "true";
  52. if(!valueResultResultItem["TagPushEvents"].isNull())
  53. resultObject.tagPushEvents = valueResultResultItem["TagPushEvents"].asString() == "true";
  54. if(!valueResultResultItem["NoteEvents"].isNull())
  55. resultObject.noteEvents = valueResultResultItem["NoteEvents"].asString() == "true";
  56. if(!valueResultResultItem["EnableSslVerification"].isNull())
  57. resultObject.enableSslVerification = valueResultResultItem["EnableSslVerification"].asString() == "true";
  58. if(!valueResultResultItem["LastTestResult"].isNull())
  59. resultObject.lastTestResult = valueResultResultItem["LastTestResult"].asString();
  60. if(!valueResultResultItem["Description"].isNull())
  61. resultObject.description = valueResultResultItem["Description"].asString();
  62. if(!valueResultResultItem["SecretToken"].isNull())
  63. resultObject.secretToken = valueResultResultItem["SecretToken"].asString();
  64. result_.push_back(resultObject);
  65. }
  66. if(!value["ErrorCode"].isNull())
  67. errorCode_ = value["ErrorCode"].asString();
  68. if(!value["Success"].isNull())
  69. success_ = value["Success"].asString() == "true";
  70. if(!value["ErrorMessage"].isNull())
  71. errorMessage_ = value["ErrorMessage"].asString();
  72. if(!value["Total"].isNull())
  73. total_ = std::stol(value["Total"].asString());
  74. }
  75. long ListRepositoryWebhookResult::getTotal()const
  76. {
  77. return total_;
  78. }
  79. std::string ListRepositoryWebhookResult::getErrorCode()const
  80. {
  81. return errorCode_;
  82. }
  83. std::string ListRepositoryWebhookResult::getErrorMessage()const
  84. {
  85. return errorMessage_;
  86. }
  87. bool ListRepositoryWebhookResult::getSuccess()const
  88. {
  89. return success_;
  90. }
  91. std::vector<ListRepositoryWebhookResult::ResultItem> ListRepositoryWebhookResult::getResult()const
  92. {
  93. return result_;
  94. }