DescribeJobGroupResult.cc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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/outboundbot/model/DescribeJobGroupResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::OutboundBot;
  19. using namespace AlibabaCloud::OutboundBot::Model;
  20. DescribeJobGroupResult::DescribeJobGroupResult() :
  21. ServiceResult()
  22. {}
  23. DescribeJobGroupResult::DescribeJobGroupResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeJobGroupResult::~DescribeJobGroupResult()
  29. {}
  30. void DescribeJobGroupResult::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["CreationTime"].isNull())
  38. jobGroup_.creationTime = std::stol(jobGroupNode["CreationTime"].asString());
  39. if(!jobGroupNode["Status"].isNull())
  40. jobGroup_.status = jobGroupNode["Status"].asString();
  41. if(!jobGroupNode["JobGroupName"].isNull())
  42. jobGroup_.jobGroupName = jobGroupNode["JobGroupName"].asString();
  43. if(!jobGroupNode["ScriptId"].isNull())
  44. jobGroup_.scriptId = jobGroupNode["ScriptId"].asString();
  45. if(!jobGroupNode["JobGroupId"].isNull())
  46. jobGroup_.jobGroupId = jobGroupNode["JobGroupId"].asString();
  47. if(!jobGroupNode["ScenarioId"].isNull())
  48. jobGroup_.scenarioId = jobGroupNode["ScenarioId"].asString();
  49. if(!jobGroupNode["JobFilePath"].isNull())
  50. jobGroup_.jobFilePath = jobGroupNode["JobFilePath"].asString();
  51. if(!jobGroupNode["JobGroupDescription"].isNull())
  52. jobGroup_.jobGroupDescription = jobGroupNode["JobGroupDescription"].asString();
  53. if(!jobGroupNode["JobDataParsingTaskId"].isNull())
  54. jobGroup_.jobDataParsingTaskId = jobGroupNode["JobDataParsingTaskId"].asString();
  55. if(!jobGroupNode["ScriptName"].isNull())
  56. jobGroup_.scriptName = jobGroupNode["ScriptName"].asString();
  57. if(!jobGroupNode["ModifyTime"].isNull())
  58. jobGroup_.modifyTime = jobGroupNode["ModifyTime"].asString();
  59. if(!jobGroupNode["ScriptVersion"].isNull())
  60. jobGroup_.scriptVersion = jobGroupNode["ScriptVersion"].asString();
  61. if(!jobGroupNode["RingingDuration"].isNull())
  62. jobGroup_.ringingDuration = std::stol(jobGroupNode["RingingDuration"].asString());
  63. auto exportProgressNode = jobGroupNode["ExportProgress"];
  64. if(!exportProgressNode["Status"].isNull())
  65. jobGroup_.exportProgress.status = exportProgressNode["Status"].asString();
  66. if(!exportProgressNode["FileHttpUrl"].isNull())
  67. jobGroup_.exportProgress.fileHttpUrl = exportProgressNode["FileHttpUrl"].asString();
  68. if(!exportProgressNode["Progress"].isNull())
  69. jobGroup_.exportProgress.progress = exportProgressNode["Progress"].asString();
  70. auto progressNode = jobGroupNode["Progress"];
  71. if(!progressNode["TotalNotAnswered"].isNull())
  72. jobGroup_.progress.totalNotAnswered = std::stoi(progressNode["TotalNotAnswered"].asString());
  73. if(!progressNode["Status"].isNull())
  74. jobGroup_.progress.status = progressNode["Status"].asString();
  75. if(!progressNode["StartTime"].isNull())
  76. jobGroup_.progress.startTime = std::stol(progressNode["StartTime"].asString());
  77. if(!progressNode["Failed"].isNull())
  78. jobGroup_.progress.failed = std::stoi(progressNode["Failed"].asString());
  79. if(!progressNode["Executing"].isNull())
  80. jobGroup_.progress.executing = std::stoi(progressNode["Executing"].asString());
  81. if(!progressNode["TotalJobs"].isNull())
  82. jobGroup_.progress.totalJobs = std::stoi(progressNode["TotalJobs"].asString());
  83. if(!progressNode["TotalCompleted"].isNull())
  84. jobGroup_.progress.totalCompleted = std::stoi(progressNode["TotalCompleted"].asString());
  85. if(!progressNode["Duration"].isNull())
  86. jobGroup_.progress.duration = std::stoi(progressNode["Duration"].asString());
  87. if(!progressNode["Scheduling"].isNull())
  88. jobGroup_.progress.scheduling = std::stoi(progressNode["Scheduling"].asString());
  89. if(!progressNode["Paused"].isNull())
  90. jobGroup_.progress.paused = std::stoi(progressNode["Paused"].asString());
  91. if(!progressNode["Cancelled"].isNull())
  92. jobGroup_.progress.cancelled = std::stoi(progressNode["Cancelled"].asString());
  93. auto allBriefsNode = progressNode["Briefs"]["KeyValuePair"];
  94. for (auto progressNodeBriefsKeyValuePair : allBriefsNode)
  95. {
  96. JobGroup::Progress::KeyValuePair keyValuePairObject;
  97. if(!progressNodeBriefsKeyValuePair["Key"].isNull())
  98. keyValuePairObject.key = progressNodeBriefsKeyValuePair["Key"].asString();
  99. if(!progressNodeBriefsKeyValuePair["Value"].isNull())
  100. keyValuePairObject.value = progressNodeBriefsKeyValuePair["Value"].asString();
  101. jobGroup_.progress.briefs.push_back(keyValuePairObject);
  102. }
  103. auto allCategoriesNode = progressNode["Categories"]["KeyValuePair"];
  104. for (auto progressNodeCategoriesKeyValuePair : allCategoriesNode)
  105. {
  106. JobGroup::Progress::KeyValuePair keyValuePairObject;
  107. if(!progressNodeCategoriesKeyValuePair["Key"].isNull())
  108. keyValuePairObject.key = progressNodeCategoriesKeyValuePair["Key"].asString();
  109. if(!progressNodeCategoriesKeyValuePair["Value"].isNull())
  110. keyValuePairObject.value = progressNodeCategoriesKeyValuePair["Value"].asString();
  111. jobGroup_.progress.categories.push_back(keyValuePairObject);
  112. }
  113. auto strategyNode = jobGroupNode["Strategy"];
  114. if(!strategyNode["Type"].isNull())
  115. jobGroup_.strategy.type = strategyNode["Type"].asString();
  116. if(!strategyNode["StrategyName"].isNull())
  117. jobGroup_.strategy.strategyName = strategyNode["StrategyName"].asString();
  118. if(!strategyNode["MaxAttemptsPerDay"].isNull())
  119. jobGroup_.strategy.maxAttemptsPerDay = std::stoi(strategyNode["MaxAttemptsPerDay"].asString());
  120. if(!strategyNode["FollowUpStrategy"].isNull())
  121. jobGroup_.strategy.followUpStrategy = strategyNode["FollowUpStrategy"].asString();
  122. if(!strategyNode["EndTime"].isNull())
  123. jobGroup_.strategy.endTime = std::stol(strategyNode["EndTime"].asString());
  124. if(!strategyNode["Customized"].isNull())
  125. jobGroup_.strategy.customized = strategyNode["Customized"].asString();
  126. if(!strategyNode["IsTemplate"].isNull())
  127. jobGroup_.strategy.isTemplate = strategyNode["IsTemplate"].asString() == "true";
  128. if(!strategyNode["StartTime"].isNull())
  129. jobGroup_.strategy.startTime = std::stol(strategyNode["StartTime"].asString());
  130. if(!strategyNode["StrategyId"].isNull())
  131. jobGroup_.strategy.strategyId = strategyNode["StrategyId"].asString();
  132. if(!strategyNode["RoutingStrategy"].isNull())
  133. jobGroup_.strategy.routingStrategy = strategyNode["RoutingStrategy"].asString();
  134. if(!strategyNode["MinAttemptInterval"].isNull())
  135. jobGroup_.strategy.minAttemptInterval = std::stoi(strategyNode["MinAttemptInterval"].asString());
  136. if(!strategyNode["StrategyDescription"].isNull())
  137. jobGroup_.strategy.strategyDescription = strategyNode["StrategyDescription"].asString();
  138. if(!strategyNode["RepeatBy"].isNull())
  139. jobGroup_.strategy.repeatBy = strategyNode["RepeatBy"].asString();
  140. auto allWorkingTimeNode = strategyNode["WorkingTime"]["TimeFrame"];
  141. for (auto strategyNodeWorkingTimeTimeFrame : allWorkingTimeNode)
  142. {
  143. JobGroup::Strategy::TimeFrame timeFrameObject;
  144. if(!strategyNodeWorkingTimeTimeFrame["EndTime"].isNull())
  145. timeFrameObject.endTime = strategyNodeWorkingTimeTimeFrame["EndTime"].asString();
  146. if(!strategyNodeWorkingTimeTimeFrame["BeginTime"].isNull())
  147. timeFrameObject.beginTime = strategyNodeWorkingTimeTimeFrame["BeginTime"].asString();
  148. jobGroup_.strategy.workingTime.push_back(timeFrameObject);
  149. }
  150. auto allRepeatDays = strategyNode["RepeatDays"]["Integer"];
  151. for (auto value : allRepeatDays)
  152. jobGroup_.strategy.repeatDays.push_back(value.asString());
  153. auto recallStrategyNode = jobGroupNode["RecallStrategy"];
  154. if(!recallStrategyNode["EmptyNumberIgnore"].isNull())
  155. jobGroup_.recallStrategy.emptyNumberIgnore = recallStrategyNode["EmptyNumberIgnore"].asString() == "true";
  156. if(!recallStrategyNode["InArrearsIgnore"].isNull())
  157. jobGroup_.recallStrategy.inArrearsIgnore = recallStrategyNode["InArrearsIgnore"].asString() == "true";
  158. if(!recallStrategyNode["OutOfServiceIgnore"].isNull())
  159. jobGroup_.recallStrategy.outOfServiceIgnore = recallStrategyNode["OutOfServiceIgnore"].asString() == "true";
  160. auto resultNode = jobGroupNode["Result"];
  161. if(!resultNode["TimeoutHangupNum"].isNull())
  162. jobGroup_.result.timeoutHangupNum = std::stoi(resultNode["TimeoutHangupNum"].asString());
  163. if(!resultNode["FinishedNum"].isNull())
  164. jobGroup_.result.finishedNum = std::stoi(resultNode["FinishedNum"].asString());
  165. if(!resultNode["NoInteractNum"].isNull())
  166. jobGroup_.result.noInteractNum = std::stoi(resultNode["NoInteractNum"].asString());
  167. if(!resultNode["ClientHangupNum"].isNull())
  168. jobGroup_.result.clientHangupNum = std::stoi(resultNode["ClientHangupNum"].asString());
  169. if(!resultNode["UnrecognizedNum"].isNull())
  170. jobGroup_.result.unrecognizedNum = std::stoi(resultNode["UnrecognizedNum"].asString());
  171. auto allCallingNumbers = jobGroupNode["CallingNumbers"]["String"];
  172. for (auto value : allCallingNumbers)
  173. jobGroup_.callingNumbers.push_back(value.asString());
  174. if(!value["HttpStatusCode"].isNull())
  175. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  176. if(!value["Code"].isNull())
  177. code_ = value["Code"].asString();
  178. if(!value["Message"].isNull())
  179. message_ = value["Message"].asString();
  180. if(!value["Success"].isNull())
  181. success_ = value["Success"].asString() == "true";
  182. }
  183. DescribeJobGroupResult::JobGroup DescribeJobGroupResult::getJobGroup()const
  184. {
  185. return jobGroup_;
  186. }
  187. std::string DescribeJobGroupResult::getMessage()const
  188. {
  189. return message_;
  190. }
  191. int DescribeJobGroupResult::getHttpStatusCode()const
  192. {
  193. return httpStatusCode_;
  194. }
  195. std::string DescribeJobGroupResult::getCode()const
  196. {
  197. return code_;
  198. }
  199. bool DescribeJobGroupResult::getSuccess()const
  200. {
  201. return success_;
  202. }