ListJobGroupsResult.cc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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/ccc/model/ListJobGroupsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CCC;
  19. using namespace AlibabaCloud::CCC::Model;
  20. ListJobGroupsResult::ListJobGroupsResult() :
  21. ServiceResult()
  22. {}
  23. ListJobGroupsResult::ListJobGroupsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListJobGroupsResult::~ListJobGroupsResult()
  29. {}
  30. void ListJobGroupsResult::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 jobGroupsNode = value["JobGroups"];
  37. if(!jobGroupsNode["TotalCount"].isNull())
  38. jobGroups_.totalCount = std::stoi(jobGroupsNode["TotalCount"].asString());
  39. if(!jobGroupsNode["PageNumber"].isNull())
  40. jobGroups_.pageNumber = std::stoi(jobGroupsNode["PageNumber"].asString());
  41. if(!jobGroupsNode["PageSize"].isNull())
  42. jobGroups_.pageSize = std::stoi(jobGroupsNode["PageSize"].asString());
  43. auto allListNode = jobGroupsNode["List"]["JobGroup"];
  44. for (auto jobGroupsNodeListJobGroup : allListNode)
  45. {
  46. JobGroups::JobGroup jobGroupObject;
  47. if(!jobGroupsNodeListJobGroup["Id"].isNull())
  48. jobGroupObject.id = jobGroupsNodeListJobGroup["Id"].asString();
  49. if(!jobGroupsNodeListJobGroup["Name"].isNull())
  50. jobGroupObject.name = jobGroupsNodeListJobGroup["Name"].asString();
  51. if(!jobGroupsNodeListJobGroup["Description"].isNull())
  52. jobGroupObject.description = jobGroupsNodeListJobGroup["Description"].asString();
  53. if(!jobGroupsNodeListJobGroup["ScenarioId"].isNull())
  54. jobGroupObject.scenarioId = jobGroupsNodeListJobGroup["ScenarioId"].asString();
  55. if(!jobGroupsNodeListJobGroup["JobFilePath"].isNull())
  56. jobGroupObject.jobFilePath = jobGroupsNodeListJobGroup["JobFilePath"].asString();
  57. if(!jobGroupsNodeListJobGroup["CreationTime"].isNull())
  58. jobGroupObject.creationTime = std::stol(jobGroupsNodeListJobGroup["CreationTime"].asString());
  59. auto strategyNode = value["Strategy"];
  60. if(!strategyNode["Id"].isNull())
  61. jobGroupObject.strategy.id = strategyNode["Id"].asString();
  62. if(!strategyNode["Name"].isNull())
  63. jobGroupObject.strategy.name = strategyNode["Name"].asString();
  64. if(!strategyNode["Description"].isNull())
  65. jobGroupObject.strategy.description = strategyNode["Description"].asString();
  66. if(!strategyNode["Type"].isNull())
  67. jobGroupObject.strategy.type = strategyNode["Type"].asString();
  68. if(!strategyNode["StartTime"].isNull())
  69. jobGroupObject.strategy.startTime = std::stol(strategyNode["StartTime"].asString());
  70. if(!strategyNode["EndTime"].isNull())
  71. jobGroupObject.strategy.endTime = std::stol(strategyNode["EndTime"].asString());
  72. if(!strategyNode["RepeatBy"].isNull())
  73. jobGroupObject.strategy.repeatBy = strategyNode["RepeatBy"].asString();
  74. if(!strategyNode["MaxAttemptsPerDay"].isNull())
  75. jobGroupObject.strategy.maxAttemptsPerDay = std::stoi(strategyNode["MaxAttemptsPerDay"].asString());
  76. if(!strategyNode["MinAttemptInterval"].isNull())
  77. jobGroupObject.strategy.minAttemptInterval = std::stoi(strategyNode["MinAttemptInterval"].asString());
  78. if(!strategyNode["Customized"].isNull())
  79. jobGroupObject.strategy.customized = strategyNode["Customized"].asString();
  80. if(!strategyNode["RoutingStrategy"].isNull())
  81. jobGroupObject.strategy.routingStrategy = strategyNode["RoutingStrategy"].asString();
  82. if(!strategyNode["FollowUpStrategy"].isNull())
  83. jobGroupObject.strategy.followUpStrategy = strategyNode["FollowUpStrategy"].asString();
  84. if(!strategyNode["IsTemplate"].isNull())
  85. jobGroupObject.strategy.isTemplate = strategyNode["IsTemplate"].asString() == "true";
  86. auto allWorkingTimeNode = strategyNode["WorkingTime"]["TimeFrame"];
  87. for (auto strategyNodeWorkingTimeTimeFrame : allWorkingTimeNode)
  88. {
  89. JobGroups::JobGroup::Strategy::TimeFrame timeFrameObject;
  90. if(!strategyNodeWorkingTimeTimeFrame["BeginTime"].isNull())
  91. timeFrameObject.beginTime = strategyNodeWorkingTimeTimeFrame["BeginTime"].asString();
  92. if(!strategyNodeWorkingTimeTimeFrame["EndTime"].isNull())
  93. timeFrameObject.endTime = strategyNodeWorkingTimeTimeFrame["EndTime"].asString();
  94. jobGroupObject.strategy.workingTime.push_back(timeFrameObject);
  95. }
  96. auto allRepeatDays = strategyNode["RepeatDays"]["Integer"];
  97. for (auto value : allRepeatDays)
  98. jobGroupObject.strategy.repeatDays.push_back(value.asString());
  99. auto progressNode = value["Progress"];
  100. if(!progressNode["TotalJobs"].isNull())
  101. jobGroupObject.progress.totalJobs = std::stoi(progressNode["TotalJobs"].asString());
  102. if(!progressNode["Status"].isNull())
  103. jobGroupObject.progress.status = progressNode["Status"].asString();
  104. if(!progressNode["TotalNotAnswered"].isNull())
  105. jobGroupObject.progress.totalNotAnswered = std::stoi(progressNode["TotalNotAnswered"].asString());
  106. if(!progressNode["TotalCompleted"].isNull())
  107. jobGroupObject.progress.totalCompleted = std::stoi(progressNode["TotalCompleted"].asString());
  108. if(!progressNode["StartTime"].isNull())
  109. jobGroupObject.progress.startTime = std::stol(progressNode["StartTime"].asString());
  110. if(!progressNode["Duration"].isNull())
  111. jobGroupObject.progress.duration = std::stoi(progressNode["Duration"].asString());
  112. auto allCategoriesNode = progressNode["Categories"]["KeyValuePair"];
  113. for (auto progressNodeCategoriesKeyValuePair : allCategoriesNode)
  114. {
  115. JobGroups::JobGroup::Progress::KeyValuePair keyValuePairObject;
  116. if(!progressNodeCategoriesKeyValuePair["Key"].isNull())
  117. keyValuePairObject.key = progressNodeCategoriesKeyValuePair["Key"].asString();
  118. if(!progressNodeCategoriesKeyValuePair["Value"].isNull())
  119. keyValuePairObject.value = progressNodeCategoriesKeyValuePair["Value"].asString();
  120. jobGroupObject.progress.categories.push_back(keyValuePairObject);
  121. }
  122. auto allCallingNumbers = value["CallingNumbers"]["String"];
  123. for (auto value : allCallingNumbers)
  124. jobGroupObject.callingNumbers.push_back(value.asString());
  125. jobGroups_.list.push_back(jobGroupObject);
  126. }
  127. if(!value["Success"].isNull())
  128. success_ = value["Success"].asString() == "true";
  129. if(!value["Code"].isNull())
  130. code_ = value["Code"].asString();
  131. if(!value["Message"].isNull())
  132. message_ = value["Message"].asString();
  133. if(!value["HttpStatusCode"].isNull())
  134. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  135. }
  136. std::string ListJobGroupsResult::getMessage()const
  137. {
  138. return message_;
  139. }
  140. int ListJobGroupsResult::getHttpStatusCode()const
  141. {
  142. return httpStatusCode_;
  143. }
  144. std::string ListJobGroupsResult::getCode()const
  145. {
  146. return code_;
  147. }
  148. ListJobGroupsResult::JobGroups ListJobGroupsResult::getJobGroups()const
  149. {
  150. return jobGroups_;
  151. }
  152. bool ListJobGroupsResult::getSuccess()const
  153. {
  154. return success_;
  155. }