DescribePricingModuleResult.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/bssopenapi/model/DescribePricingModuleResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::BssOpenApi;
  19. using namespace AlibabaCloud::BssOpenApi::Model;
  20. DescribePricingModuleResult::DescribePricingModuleResult() :
  21. ServiceResult()
  22. {}
  23. DescribePricingModuleResult::DescribePricingModuleResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribePricingModuleResult::~DescribePricingModuleResult()
  29. {}
  30. void DescribePricingModuleResult::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 allModuleList = value["ModuleList"]["Module"];
  38. for (auto value : allModuleList)
  39. {
  40. Data::Module moduleObject;
  41. if(!value["ModuleCode"].isNull())
  42. moduleObject.moduleCode = value["ModuleCode"].asString();
  43. if(!value["ModuleName"].isNull())
  44. moduleObject.moduleName = value["ModuleName"].asString();
  45. if(!value["PriceType"].isNull())
  46. moduleObject.priceType = value["PriceType"].asString();
  47. if(!value["Currency"].isNull())
  48. moduleObject.currency = value["Currency"].asString();
  49. auto allConfigList = value["ConfigList"]["ConfigList"];
  50. for (auto value : allConfigList)
  51. moduleObject.configList.push_back(value.asString());
  52. data_.moduleList.push_back(moduleObject);
  53. }
  54. auto allAttributeList = value["AttributeList"]["Attribute"];
  55. for (auto value : allAttributeList)
  56. {
  57. Data::Attribute attributeObject;
  58. if(!value["Code"].isNull())
  59. attributeObject.code = value["Code"].asString();
  60. if(!value["Name"].isNull())
  61. attributeObject.name = value["Name"].asString();
  62. if(!value["Unit"].isNull())
  63. attributeObject.unit = value["Unit"].asString();
  64. auto allValues = value["Values"]["AttributeValue"];
  65. for (auto value : allValues)
  66. {
  67. Data::Attribute::AttributeValue valuesObject;
  68. if(!value["Type"].isNull())
  69. valuesObject.type = value["Type"].asString();
  70. if(!value["Name"].isNull())
  71. valuesObject.name = value["Name"].asString();
  72. if(!value["Value"].isNull())
  73. valuesObject.value = value["Value"].asString();
  74. if(!value["Remark"].isNull())
  75. valuesObject.remark = value["Remark"].asString();
  76. attributeObject.values.push_back(valuesObject);
  77. }
  78. data_.attributeList.push_back(attributeObject);
  79. }
  80. if(!value["Success"].isNull())
  81. success_ = value["Success"].asString() == "true";
  82. if(!value["Code"].isNull())
  83. code_ = value["Code"].asString();
  84. if(!value["Message"].isNull())
  85. message_ = value["Message"].asString();
  86. }
  87. std::string DescribePricingModuleResult::getMessage()const
  88. {
  89. return message_;
  90. }
  91. DescribePricingModuleResult::Data DescribePricingModuleResult::getData()const
  92. {
  93. return data_;
  94. }
  95. std::string DescribePricingModuleResult::getCode()const
  96. {
  97. return code_;
  98. }
  99. bool DescribePricingModuleResult::getSuccess()const
  100. {
  101. return success_;
  102. }