QueryAuthenticationResult.cc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/linkface/model/QueryAuthenticationResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::LinkFace;
  19. using namespace AlibabaCloud::LinkFace::Model;
  20. QueryAuthenticationResult::QueryAuthenticationResult() :
  21. ServiceResult()
  22. {}
  23. QueryAuthenticationResult::QueryAuthenticationResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryAuthenticationResult::~QueryAuthenticationResult()
  29. {}
  30. void QueryAuthenticationResult::parse(const std::string &payload)
  31. {
  32. Json::CharReaderBuilder builder;
  33. Json::CharReader *reader = builder.newCharReader();
  34. Json::Value *val;
  35. Json::Value value;
  36. JSONCPP_STRING *errs;
  37. reader->parse(payload.data(), payload.data() + payload.size(), val, errs);
  38. value = *val;
  39. setRequestId(value["RequestId"].asString());
  40. auto allData = value["Data"]["DataItem"];
  41. for (auto value : allData)
  42. {
  43. DataItem dataObject;
  44. if(!value["LicenseType"].isNull())
  45. dataObject.licenseType = std::stoi(value["LicenseType"].asString());
  46. if(!value["IotId"].isNull())
  47. dataObject.iotId = value["IotId"].asString();
  48. if(!value["BeginTime"].isNull())
  49. dataObject.beginTime = value["BeginTime"].asString();
  50. if(!value["ExpiredTime"].isNull())
  51. dataObject.expiredTime = value["ExpiredTime"].asString();
  52. if(!value["ApkPubkey"].isNull())
  53. dataObject.apkPubkey = value["ApkPubkey"].asString();
  54. if(!value["PackageName"].isNull())
  55. dataObject.packageName = value["PackageName"].asString();
  56. if(!value["ClientId"].isNull())
  57. dataObject.clientId = value["ClientId"].asString();
  58. if(!value["ProductKey"].isNull())
  59. dataObject.productKey = value["ProductKey"].asString();
  60. if(!value["DeviceName"].isNull())
  61. dataObject.deviceName = value["DeviceName"].asString();
  62. data_.push_back(dataObject);
  63. }
  64. if(!value["Code"].isNull())
  65. code_ = std::stoi(value["Code"].asString());
  66. if(!value["Message"].isNull())
  67. message_ = value["Message"].asString();
  68. if(!value["PageCount"].isNull())
  69. pageCount_ = std::stoi(value["PageCount"].asString());
  70. if(!value["PageSize"].isNull())
  71. pageSize_ = std::stoi(value["PageSize"].asString());
  72. if(!value["Page"].isNull())
  73. page_ = std::stoi(value["Page"].asString());
  74. if(!value["Total"].isNull())
  75. total_ = std::stoi(value["Total"].asString());
  76. if(!value["Success"].isNull())
  77. success_ = value["Success"].asString() == "true";
  78. }
  79. std::string QueryAuthenticationResult::getMessage()const
  80. {
  81. return message_;
  82. }
  83. int QueryAuthenticationResult::getPageCount()const
  84. {
  85. return pageCount_;
  86. }
  87. int QueryAuthenticationResult::getPageSize()const
  88. {
  89. return pageSize_;
  90. }
  91. int QueryAuthenticationResult::getTotal()const
  92. {
  93. return total_;
  94. }
  95. std::vector<QueryAuthenticationResult::DataItem> QueryAuthenticationResult::getData()const
  96. {
  97. return data_;
  98. }
  99. int QueryAuthenticationResult::getPage()const
  100. {
  101. return page_;
  102. }
  103. int QueryAuthenticationResult::getCode()const
  104. {
  105. return code_;
  106. }
  107. bool QueryAuthenticationResult::getSuccess()const
  108. {
  109. return success_;
  110. }