BatchCheckImportDeviceResult.cc 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/BatchCheckImportDeviceResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Iot;
  19. using namespace AlibabaCloud::Iot::Model;
  20. BatchCheckImportDeviceResult::BatchCheckImportDeviceResult() :
  21. ServiceResult()
  22. {}
  23. BatchCheckImportDeviceResult::BatchCheckImportDeviceResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. BatchCheckImportDeviceResult::~BatchCheckImportDeviceResult()
  29. {}
  30. void BatchCheckImportDeviceResult::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. auto allInvalidDetailListNode = dataNode["InvalidDetailList"]["InvalidDetailListItem"];
  38. for (auto dataNodeInvalidDetailListInvalidDetailListItem : allInvalidDetailListNode)
  39. {
  40. Data::InvalidDetailListItem invalidDetailListItemObject;
  41. if(!dataNodeInvalidDetailListInvalidDetailListItem["DeviceName"].isNull())
  42. invalidDetailListItemObject.deviceName = dataNodeInvalidDetailListInvalidDetailListItem["DeviceName"].asString();
  43. if(!dataNodeInvalidDetailListInvalidDetailListItem["DeviceSecret"].isNull())
  44. invalidDetailListItemObject.deviceSecret = dataNodeInvalidDetailListInvalidDetailListItem["DeviceSecret"].asString();
  45. if(!dataNodeInvalidDetailListInvalidDetailListItem["Sn"].isNull())
  46. invalidDetailListItemObject.sn = dataNodeInvalidDetailListInvalidDetailListItem["Sn"].asString();
  47. if(!dataNodeInvalidDetailListInvalidDetailListItem["ErrorMsg"].isNull())
  48. invalidDetailListItemObject.errorMsg = dataNodeInvalidDetailListInvalidDetailListItem["ErrorMsg"].asString();
  49. data_.invalidDetailList.push_back(invalidDetailListItemObject);
  50. }
  51. auto allInvalidDeviceNameList = dataNode["InvalidDeviceNameList"]["invalidDeviceName"];
  52. for (auto value : allInvalidDeviceNameList)
  53. data_.invalidDeviceNameList.push_back(value.asString());
  54. auto allInvalidDeviceSecretList = dataNode["InvalidDeviceSecretList"]["invalidDeviceSecret"];
  55. for (auto value : allInvalidDeviceSecretList)
  56. data_.invalidDeviceSecretList.push_back(value.asString());
  57. auto allInvalidSnList = dataNode["InvalidSnList"]["invalidSn"];
  58. for (auto value : allInvalidSnList)
  59. data_.invalidSnList.push_back(value.asString());
  60. auto allRepeatedDeviceNameList = dataNode["RepeatedDeviceNameList"]["repeatedDeviceName"];
  61. for (auto value : allRepeatedDeviceNameList)
  62. data_.repeatedDeviceNameList.push_back(value.asString());
  63. if(!value["Success"].isNull())
  64. success_ = value["Success"].asString() == "true";
  65. if(!value["Code"].isNull())
  66. code_ = value["Code"].asString();
  67. if(!value["ErrorMessage"].isNull())
  68. errorMessage_ = value["ErrorMessage"].asString();
  69. }
  70. BatchCheckImportDeviceResult::Data BatchCheckImportDeviceResult::getData()const
  71. {
  72. return data_;
  73. }
  74. std::string BatchCheckImportDeviceResult::getErrorMessage()const
  75. {
  76. return errorMessage_;
  77. }
  78. std::string BatchCheckImportDeviceResult::getCode()const
  79. {
  80. return code_;
  81. }
  82. bool BatchCheckImportDeviceResult::getSuccess()const
  83. {
  84. return success_;
  85. }