QueryProductResult.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/QueryProductResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. QueryProductResult::QueryProductResult() :
  21. ServiceResult()
  22. {}
  23. QueryProductResult::QueryProductResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryProductResult::~QueryProductResult()
  29. {}
  30. void QueryProductResult::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["GmtCreate"].isNull())
  38. data_.gmtCreate = std::stol(dataNode["GmtCreate"].asString());
  39. if(!dataNode["DataFormat"].isNull())
  40. data_.dataFormat = std::stoi(dataNode["DataFormat"].asString());
  41. if(!dataNode["Description"].isNull())
  42. data_.description = dataNode["Description"].asString();
  43. if(!dataNode["DeviceCount"].isNull())
  44. data_.deviceCount = std::stoi(dataNode["DeviceCount"].asString());
  45. if(!dataNode["NodeType"].isNull())
  46. data_.nodeType = std::stoi(dataNode["NodeType"].asString());
  47. if(!dataNode["ProductKey"].isNull())
  48. data_.productKey = dataNode["ProductKey"].asString();
  49. if(!dataNode["ProductName"].isNull())
  50. data_.productName = dataNode["ProductName"].asString();
  51. if(!dataNode["ProductSecret"].isNull())
  52. data_.productSecret = dataNode["ProductSecret"].asString();
  53. if(!dataNode["CategoryName"].isNull())
  54. data_.categoryName = dataNode["CategoryName"].asString();
  55. if(!dataNode["CategoryKey"].isNull())
  56. data_.categoryKey = dataNode["CategoryKey"].asString();
  57. if(!dataNode["AliyunCommodityCode"].isNull())
  58. data_.aliyunCommodityCode = dataNode["AliyunCommodityCode"].asString();
  59. if(!dataNode["Id2"].isNull())
  60. data_.id2 = dataNode["Id2"].asString() == "true";
  61. if(!dataNode["ProtocolType"].isNull())
  62. data_.protocolType = dataNode["ProtocolType"].asString();
  63. if(!dataNode["ProductStatus"].isNull())
  64. data_.productStatus = dataNode["ProductStatus"].asString();
  65. if(!dataNode["Owner"].isNull())
  66. data_.owner = dataNode["Owner"].asString() == "true";
  67. if(!value["Success"].isNull())
  68. success_ = value["Success"].asString() == "true";
  69. if(!value["Code"].isNull())
  70. code_ = value["Code"].asString();
  71. if(!value["ErrorMessage"].isNull())
  72. errorMessage_ = value["ErrorMessage"].asString();
  73. }
  74. QueryProductResult::Data QueryProductResult::getData()const
  75. {
  76. return data_;
  77. }
  78. std::string QueryProductResult::getErrorMessage()const
  79. {
  80. return errorMessage_;
  81. }
  82. std::string QueryProductResult::getCode()const
  83. {
  84. return code_;
  85. }
  86. bool QueryProductResult::getSuccess()const
  87. {
  88. return success_;
  89. }