QueryJobsWithResultResult.cc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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/QueryJobsWithResultResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::OutboundBot;
  19. using namespace AlibabaCloud::OutboundBot::Model;
  20. QueryJobsWithResultResult::QueryJobsWithResultResult() :
  21. ServiceResult()
  22. {}
  23. QueryJobsWithResultResult::QueryJobsWithResultResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryJobsWithResultResult::~QueryJobsWithResultResult()
  29. {}
  30. void QueryJobsWithResultResult::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 jobsNode = value["Jobs"];
  37. if(!jobsNode["PageNumber"].isNull())
  38. jobs_.pageNumber = std::stoi(jobsNode["PageNumber"].asString());
  39. if(!jobsNode["PageSize"].isNull())
  40. jobs_.pageSize = std::stoi(jobsNode["PageSize"].asString());
  41. if(!jobsNode["PageCount"].isNull())
  42. jobs_.pageCount = std::stoi(jobsNode["PageCount"].asString());
  43. if(!jobsNode["RowCount"].isNull())
  44. jobs_.rowCount = std::stoi(jobsNode["RowCount"].asString());
  45. auto allListNode = jobsNode["List"]["Job"];
  46. for (auto jobsNodeListJob : allListNode)
  47. {
  48. Jobs::Job jobObject;
  49. if(!jobsNodeListJob["Status"].isNull())
  50. jobObject.status = jobsNodeListJob["Status"].asString();
  51. if(!jobsNodeListJob["StatusName"].isNull())
  52. jobObject.statusName = jobsNodeListJob["StatusName"].asString();
  53. if(!jobsNodeListJob["JobFailureReason"].isNull())
  54. jobObject.jobFailureReason = jobsNodeListJob["JobFailureReason"].asString();
  55. if(!jobsNodeListJob["Id"].isNull())
  56. jobObject.id = jobsNodeListJob["Id"].asString();
  57. auto latestTaskNode = value["LatestTask"];
  58. if(!latestTaskNode["Status"].isNull())
  59. jobObject.latestTask.status = latestTaskNode["Status"].asString();
  60. if(!latestTaskNode["TaskEndReason"].isNull())
  61. jobObject.latestTask.taskEndReason = latestTaskNode["TaskEndReason"].asString();
  62. if(!latestTaskNode["HasAnswered"].isNull())
  63. jobObject.latestTask.hasAnswered = latestTaskNode["HasAnswered"].asString() == "true";
  64. if(!latestTaskNode["CallDuration"].isNull())
  65. jobObject.latestTask.callDuration = std::stoi(latestTaskNode["CallDuration"].asString());
  66. if(!latestTaskNode["HasReachedEndOfFlow"].isNull())
  67. jobObject.latestTask.hasReachedEndOfFlow = latestTaskNode["HasReachedEndOfFlow"].asString() == "true";
  68. if(!latestTaskNode["StatusName"].isNull())
  69. jobObject.latestTask.statusName = latestTaskNode["StatusName"].asString();
  70. if(!latestTaskNode["CallTime"].isNull())
  71. jobObject.latestTask.callTime = std::stol(latestTaskNode["CallTime"].asString());
  72. if(!latestTaskNode["CallDurationDisplay"].isNull())
  73. jobObject.latestTask.callDurationDisplay = latestTaskNode["CallDurationDisplay"].asString();
  74. if(!latestTaskNode["HasHangUpByRejection"].isNull())
  75. jobObject.latestTask.hasHangUpByRejection = latestTaskNode["HasHangUpByRejection"].asString() == "true";
  76. auto allExtrasNode = latestTaskNode["Extras"]["Extra"];
  77. for (auto latestTaskNodeExtrasExtra : allExtrasNode)
  78. {
  79. Jobs::Job::LatestTask::Extra extraObject;
  80. if(!latestTaskNodeExtrasExtra["Key"].isNull())
  81. extraObject.key = latestTaskNodeExtrasExtra["Key"].asString();
  82. if(!latestTaskNodeExtrasExtra["Value"].isNull())
  83. extraObject.value = latestTaskNodeExtrasExtra["Value"].asString();
  84. jobObject.latestTask.extras.push_back(extraObject);
  85. }
  86. auto allTagHitsNode = latestTaskNode["TagHits"]["TagHit"];
  87. for (auto latestTaskNodeTagHitsTagHit : allTagHitsNode)
  88. {
  89. Jobs::Job::LatestTask::TagHit tagHitObject;
  90. if(!latestTaskNodeTagHitsTagHit["TagName"].isNull())
  91. tagHitObject.tagName = latestTaskNodeTagHitsTagHit["TagName"].asString();
  92. if(!latestTaskNodeTagHitsTagHit["TagGroup"].isNull())
  93. tagHitObject.tagGroup = latestTaskNodeTagHitsTagHit["TagGroup"].asString();
  94. jobObject.latestTask.tagHits.push_back(tagHitObject);
  95. }
  96. auto allDialExceptionCodesNode = latestTaskNode["DialExceptionCodes"]["ExceptionCode"];
  97. for (auto latestTaskNodeDialExceptionCodesExceptionCode : allDialExceptionCodesNode)
  98. {
  99. Jobs::Job::LatestTask::ExceptionCode exceptionCodeObject;
  100. if(!latestTaskNodeDialExceptionCodesExceptionCode["Code"].isNull())
  101. exceptionCodeObject.code = latestTaskNodeDialExceptionCodesExceptionCode["Code"].asString();
  102. if(!latestTaskNodeDialExceptionCodesExceptionCode["Hint"].isNull())
  103. exceptionCodeObject.hint = latestTaskNodeDialExceptionCodesExceptionCode["Hint"].asString();
  104. jobObject.latestTask.dialExceptionCodes.push_back(exceptionCodeObject);
  105. }
  106. auto contactNode = latestTaskNode["Contact"];
  107. if(!contactNode["Round"].isNull())
  108. jobObject.latestTask.contact.round = std::stoi(contactNode["Round"].asString());
  109. if(!contactNode["JobUuid"].isNull())
  110. jobObject.latestTask.contact.jobUuid = contactNode["JobUuid"].asString();
  111. if(!contactNode["PreferredPhoneNumber"].isNull())
  112. jobObject.latestTask.contact.preferredPhoneNumber = contactNode["PreferredPhoneNumber"].asString();
  113. if(!contactNode["PhoneNumber"].isNull())
  114. jobObject.latestTask.contact.phoneNumber = contactNode["PhoneNumber"].asString();
  115. if(!contactNode["State"].isNull())
  116. jobObject.latestTask.contact.state = contactNode["State"].asString();
  117. if(!contactNode["Honorific"].isNull())
  118. jobObject.latestTask.contact.honorific = contactNode["Honorific"].asString();
  119. if(!contactNode["Name"].isNull())
  120. jobObject.latestTask.contact.name = contactNode["Name"].asString();
  121. if(!contactNode["Role"].isNull())
  122. jobObject.latestTask.contact.role = contactNode["Role"].asString();
  123. if(!contactNode["Id"].isNull())
  124. jobObject.latestTask.contact.id = contactNode["Id"].asString();
  125. if(!contactNode["ReferenceId"].isNull())
  126. jobObject.latestTask.contact.referenceId = contactNode["ReferenceId"].asString();
  127. jobs_.list.push_back(jobObject);
  128. }
  129. auto allVariableNames = value["VariableNames"]["VariableName"];
  130. for (const auto &item : allVariableNames)
  131. variableNames_.push_back(item.asString());
  132. if(!value["HttpStatusCode"].isNull())
  133. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  134. if(!value["Code"].isNull())
  135. code_ = value["Code"].asString();
  136. if(!value["Message"].isNull())
  137. message_ = value["Message"].asString();
  138. if(!value["Success"].isNull())
  139. success_ = value["Success"].asString() == "true";
  140. }
  141. std::vector<std::string> QueryJobsWithResultResult::getVariableNames()const
  142. {
  143. return variableNames_;
  144. }
  145. std::string QueryJobsWithResultResult::getMessage()const
  146. {
  147. return message_;
  148. }
  149. QueryJobsWithResultResult::Jobs QueryJobsWithResultResult::getJobs()const
  150. {
  151. return jobs_;
  152. }
  153. int QueryJobsWithResultResult::getHttpStatusCode()const
  154. {
  155. return httpStatusCode_;
  156. }
  157. std::string QueryJobsWithResultResult::getCode()const
  158. {
  159. return code_;
  160. }
  161. bool QueryJobsWithResultResult::getSuccess()const
  162. {
  163. return success_;
  164. }