QueryDeviceDetailResult.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/iot/model/QueryDeviceDetailResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. QueryDeviceDetailResult::QueryDeviceDetailResult() :
  21. ServiceResult()
  22. {}
  23. QueryDeviceDetailResult::QueryDeviceDetailResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryDeviceDetailResult::~QueryDeviceDetailResult()
  29. {}
  30. void QueryDeviceDetailResult::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 dataNode = value["Data"];
  37. if(!dataNode["IotId"].isNull())
  38. data_.iotId = dataNode["IotId"].asString();
  39. if(!dataNode["ProductKey"].isNull())
  40. data_.productKey = dataNode["ProductKey"].asString();
  41. if(!dataNode["ProductName"].isNull())
  42. data_.productName = dataNode["ProductName"].asString();
  43. if(!dataNode["DeviceName"].isNull())
  44. data_.deviceName = dataNode["DeviceName"].asString();
  45. if(!dataNode["DeviceSecret"].isNull())
  46. data_.deviceSecret = dataNode["DeviceSecret"].asString();
  47. if(!dataNode["FirmwareVersion"].isNull())
  48. data_.firmwareVersion = dataNode["FirmwareVersion"].asString();
  49. if(!dataNode["GmtCreate"].isNull())
  50. data_.gmtCreate = dataNode["GmtCreate"].asString();
  51. if(!dataNode["UtcCreate"].isNull())
  52. data_.utcCreate = dataNode["UtcCreate"].asString();
  53. if(!dataNode["GmtActive"].isNull())
  54. data_.gmtActive = dataNode["GmtActive"].asString();
  55. if(!dataNode["UtcActive"].isNull())
  56. data_.utcActive = dataNode["UtcActive"].asString();
  57. if(!dataNode["GmtOnline"].isNull())
  58. data_.gmtOnline = dataNode["GmtOnline"].asString();
  59. if(!dataNode["UtcOnline"].isNull())
  60. data_.utcOnline = dataNode["UtcOnline"].asString();
  61. if(!dataNode["Status"].isNull())
  62. data_.status = dataNode["Status"].asString();
  63. if(!dataNode["IpAddress"].isNull())
  64. data_.ipAddress = dataNode["IpAddress"].asString();
  65. if(!dataNode["NodeType"].isNull())
  66. data_.nodeType = std::stoi(dataNode["NodeType"].asString());
  67. if(!dataNode["Region"].isNull())
  68. data_.region = dataNode["Region"].asString();
  69. if(!dataNode["Owner"].isNull())
  70. data_.owner = dataNode["Owner"].asString() == "true";
  71. if(!dataNode["Nickname"].isNull())
  72. data_.nickname = dataNode["Nickname"].asString();
  73. if(!value["Success"].isNull())
  74. success_ = value["Success"].asString() == "true";
  75. if(!value["Code"].isNull())
  76. code_ = value["Code"].asString();
  77. if(!value["ErrorMessage"].isNull())
  78. errorMessage_ = value["ErrorMessage"].asString();
  79. }
  80. QueryDeviceDetailResult::Data QueryDeviceDetailResult::getData()const
  81. {
  82. return data_;
  83. }
  84. std::string QueryDeviceDetailResult::getErrorMessage()const
  85. {
  86. return errorMessage_;
  87. }
  88. std::string QueryDeviceDetailResult::getCode()const
  89. {
  90. return code_;
  91. }
  92. bool QueryDeviceDetailResult::getSuccess()const
  93. {
  94. return success_;
  95. }