GetJobGroupResult.cc 5.9 KB

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