ListConversationsResult.cc 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/voicenavigator/model/ListConversationsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::VoiceNavigator;
  19. using namespace AlibabaCloud::VoiceNavigator::Model;
  20. ListConversationsResult::ListConversationsResult() :
  21. ServiceResult()
  22. {}
  23. ListConversationsResult::ListConversationsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListConversationsResult::~ListConversationsResult()
  29. {}
  30. void ListConversationsResult::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 allConversationsNode = value["Conversations"]["Conversation"];
  37. for (auto valueConversationsConversation : allConversationsNode)
  38. {
  39. Conversation conversationsObject;
  40. if(!valueConversationsConversation["EndTime"].isNull())
  41. conversationsObject.endTime = std::stol(valueConversationsConversation["EndTime"].asString());
  42. if(!valueConversationsConversation["HasToAgent"].isNull())
  43. conversationsObject.hasToAgent = valueConversationsConversation["HasToAgent"].asString() == "true";
  44. if(!valueConversationsConversation["StartTime"].isNull())
  45. conversationsObject.startTime = std::stol(valueConversationsConversation["StartTime"].asString());
  46. if(!valueConversationsConversation["SkillGroup"].isNull())
  47. conversationsObject.skillGroup = valueConversationsConversation["SkillGroup"].asString();
  48. if(!valueConversationsConversation["ConversationId"].isNull())
  49. conversationsObject.conversationId = valueConversationsConversation["ConversationId"].asString();
  50. if(!valueConversationsConversation["CallingNumber"].isNull())
  51. conversationsObject.callingNumber = valueConversationsConversation["CallingNumber"].asString();
  52. if(!valueConversationsConversation["EndReason"].isNull())
  53. conversationsObject.endReason = std::stoi(valueConversationsConversation["EndReason"].asString());
  54. if(!valueConversationsConversation["Rounds"].isNull())
  55. conversationsObject.rounds = std::stoi(valueConversationsConversation["Rounds"].asString());
  56. if(!valueConversationsConversation["HasLastPlaybackCompleted"].isNull())
  57. conversationsObject.hasLastPlaybackCompleted = valueConversationsConversation["HasLastPlaybackCompleted"].asString() == "true";
  58. conversations_.push_back(conversationsObject);
  59. }
  60. if(!value["TotalCount"].isNull())
  61. totalCount_ = std::stol(value["TotalCount"].asString());
  62. if(!value["PageSize"].isNull())
  63. pageSize_ = std::stoi(value["PageSize"].asString());
  64. if(!value["PageNumber"].isNull())
  65. pageNumber_ = std::stoi(value["PageNumber"].asString());
  66. }
  67. long ListConversationsResult::getTotalCount()const
  68. {
  69. return totalCount_;
  70. }
  71. int ListConversationsResult::getPageSize()const
  72. {
  73. return pageSize_;
  74. }
  75. int ListConversationsResult::getPageNumber()const
  76. {
  77. return pageNumber_;
  78. }
  79. std::vector<ListConversationsResult::Conversation> ListConversationsResult::getConversations()const
  80. {
  81. return conversations_;
  82. }