GetGatewayResult.cc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/linkwan/model/GetGatewayResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::LinkWAN;
  19. using namespace AlibabaCloud::LinkWAN::Model;
  20. GetGatewayResult::GetGatewayResult() :
  21. ServiceResult()
  22. {}
  23. GetGatewayResult::GetGatewayResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetGatewayResult::~GetGatewayResult()
  29. {}
  30. void GetGatewayResult::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["GwEui"].isNull())
  38. data_.gwEui = dataNode["GwEui"].asString();
  39. if(!dataNode["OnlineState"].isNull())
  40. data_.onlineState = dataNode["OnlineState"].asString();
  41. if(!dataNode["Name"].isNull())
  42. data_.name = dataNode["Name"].asString();
  43. if(!dataNode["Description"].isNull())
  44. data_.description = dataNode["Description"].asString();
  45. if(!dataNode["City"].isNull())
  46. data_.city = dataNode["City"].asString();
  47. if(!dataNode["District"].isNull())
  48. data_.district = dataNode["District"].asString();
  49. if(!dataNode["Address"].isNull())
  50. data_.address = dataNode["Address"].asString();
  51. if(!dataNode["AddressCode"].isNull())
  52. data_.addressCode = std::stol(dataNode["AddressCode"].asString());
  53. if(!dataNode["GisCoordinateSystem"].isNull())
  54. data_.gisCoordinateSystem = dataNode["GisCoordinateSystem"].asString();
  55. if(!dataNode["Longitude"].isNull())
  56. data_.longitude = std::stof(dataNode["Longitude"].asString());
  57. if(!dataNode["Latitude"].isNull())
  58. data_.latitude = std::stof(dataNode["Latitude"].asString());
  59. if(!dataNode["FreqBandPlanGroupId"].isNull())
  60. data_.freqBandPlanGroupId = std::stol(dataNode["FreqBandPlanGroupId"].asString());
  61. if(!dataNode["CommunicationMode"].isNull())
  62. data_.communicationMode = dataNode["CommunicationMode"].asString();
  63. if(!dataNode["TimeCorrectable"].isNull())
  64. data_.timeCorrectable = dataNode["TimeCorrectable"].asString() == "true";
  65. if(!dataNode["ClassBSupported"].isNull())
  66. data_.classBSupported = dataNode["ClassBSupported"].asString() == "true";
  67. if(!dataNode["ClassBWorking"].isNull())
  68. data_.classBWorking = dataNode["ClassBWorking"].asString() == "true";
  69. if(!dataNode["Enabled"].isNull())
  70. data_.enabled = dataNode["Enabled"].asString() == "true";
  71. if(!dataNode["OnlineStateChangedMillis"].isNull())
  72. data_.onlineStateChangedMillis = std::stol(dataNode["OnlineStateChangedMillis"].asString());
  73. if(!dataNode["EmbeddedNsId"].isNull())
  74. data_.embeddedNsId = dataNode["EmbeddedNsId"].asString();
  75. if(!dataNode["ChargeStatus"].isNull())
  76. data_.chargeStatus = dataNode["ChargeStatus"].asString();
  77. if(!dataNode["AuthTypes"].isNull())
  78. data_.authTypes = dataNode["AuthTypes"].asString();
  79. if(!value["Success"].isNull())
  80. success_ = value["Success"].asString() == "true";
  81. }
  82. GetGatewayResult::Data GetGatewayResult::getData()const
  83. {
  84. return data_;
  85. }
  86. bool GetGatewayResult::getSuccess()const
  87. {
  88. return success_;
  89. }