DescribeItemsResult.cc 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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/cloudesl/model/DescribeItemsResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Cloudesl;
  19. using namespace AlibabaCloud::Cloudesl::Model;
  20. DescribeItemsResult::DescribeItemsResult() :
  21. ServiceResult()
  22. {}
  23. DescribeItemsResult::DescribeItemsResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeItemsResult::~DescribeItemsResult()
  29. {}
  30. void DescribeItemsResult::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 allItemsNode = value["Items"]["ItemInfo"];
  37. for (auto valueItemsItemInfo : allItemsNode)
  38. {
  39. ItemInfo itemsObject;
  40. if(!valueItemsItemInfo["CategoryName"].isNull())
  41. itemsObject.categoryName = valueItemsItemInfo["CategoryName"].asString();
  42. if(!valueItemsItemInfo["EnergyEfficiency"].isNull())
  43. itemsObject.energyEfficiency = valueItemsItemInfo["EnergyEfficiency"].asString();
  44. if(!valueItemsItemInfo["CustomizeFeatureO"].isNull())
  45. itemsObject.customizeFeatureO = valueItemsItemInfo["CustomizeFeatureO"].asString();
  46. if(!valueItemsItemInfo["Manufacturer"].isNull())
  47. itemsObject.manufacturer = valueItemsItemInfo["Manufacturer"].asString();
  48. if(!valueItemsItemInfo["CustomizeFeatureM"].isNull())
  49. itemsObject.customizeFeatureM = valueItemsItemInfo["CustomizeFeatureM"].asString();
  50. if(!valueItemsItemInfo["CustomizeFeatureN"].isNull())
  51. itemsObject.customizeFeatureN = valueItemsItemInfo["CustomizeFeatureN"].asString();
  52. if(!valueItemsItemInfo["CustomizeFeatureK"].isNull())
  53. itemsObject.customizeFeatureK = valueItemsItemInfo["CustomizeFeatureK"].asString();
  54. if(!valueItemsItemInfo["CustomizeFeatureL"].isNull())
  55. itemsObject.customizeFeatureL = valueItemsItemInfo["CustomizeFeatureL"].asString();
  56. if(!valueItemsItemInfo["PromotionEnd"].isNull())
  57. itemsObject.promotionEnd = valueItemsItemInfo["PromotionEnd"].asString();
  58. if(!valueItemsItemInfo["OriginalPrice"].isNull())
  59. itemsObject.originalPrice = std::stoi(valueItemsItemInfo["OriginalPrice"].asString());
  60. if(!valueItemsItemInfo["CustomizeFeatureI"].isNull())
  61. itemsObject.customizeFeatureI = valueItemsItemInfo["CustomizeFeatureI"].asString();
  62. if(!valueItemsItemInfo["ItemTitle"].isNull())
  63. itemsObject.itemTitle = valueItemsItemInfo["ItemTitle"].asString();
  64. if(!valueItemsItemInfo["CustomizeFeatureJ"].isNull())
  65. itemsObject.customizeFeatureJ = valueItemsItemInfo["CustomizeFeatureJ"].asString();
  66. if(!valueItemsItemInfo["CustomizeFeatureG"].isNull())
  67. itemsObject.customizeFeatureG = valueItemsItemInfo["CustomizeFeatureG"].asString();
  68. if(!valueItemsItemInfo["SaleSpec"].isNull())
  69. itemsObject.saleSpec = valueItemsItemInfo["SaleSpec"].asString();
  70. if(!valueItemsItemInfo["CustomizeFeatureH"].isNull())
  71. itemsObject.customizeFeatureH = valueItemsItemInfo["CustomizeFeatureH"].asString();
  72. if(!valueItemsItemInfo["CustomizeFeatureE"].isNull())
  73. itemsObject.customizeFeatureE = valueItemsItemInfo["CustomizeFeatureE"].asString();
  74. if(!valueItemsItemInfo["CustomizeFeatureF"].isNull())
  75. itemsObject.customizeFeatureF = valueItemsItemInfo["CustomizeFeatureF"].asString();
  76. if(!valueItemsItemInfo["CustomizeFeatureC"].isNull())
  77. itemsObject.customizeFeatureC = valueItemsItemInfo["CustomizeFeatureC"].asString();
  78. if(!valueItemsItemInfo["CustomizeFeatureD"].isNull())
  79. itemsObject.customizeFeatureD = valueItemsItemInfo["CustomizeFeatureD"].asString();
  80. if(!valueItemsItemInfo["CustomizeFeatureA"].isNull())
  81. itemsObject.customizeFeatureA = valueItemsItemInfo["CustomizeFeatureA"].asString();
  82. if(!valueItemsItemInfo["CustomizeFeatureB"].isNull())
  83. itemsObject.customizeFeatureB = valueItemsItemInfo["CustomizeFeatureB"].asString();
  84. if(!valueItemsItemInfo["TaxFee"].isNull())
  85. itemsObject.taxFee = valueItemsItemInfo["TaxFee"].asString();
  86. if(!valueItemsItemInfo["PromotionText"].isNull())
  87. itemsObject.promotionText = valueItemsItemInfo["PromotionText"].asString();
  88. if(!valueItemsItemInfo["MemberPrice"].isNull())
  89. itemsObject.memberPrice = std::stoi(valueItemsItemInfo["MemberPrice"].asString());
  90. if(!valueItemsItemInfo["SupplierName"].isNull())
  91. itemsObject.supplierName = valueItemsItemInfo["SupplierName"].asString();
  92. if(!valueItemsItemInfo["ForestFirstId"].isNull())
  93. itemsObject.forestFirstId = valueItemsItemInfo["ForestFirstId"].asString();
  94. if(!valueItemsItemInfo["ModelNumber"].isNull())
  95. itemsObject.modelNumber = valueItemsItemInfo["ModelNumber"].asString();
  96. if(!valueItemsItemInfo["ItemShortTitle"].isNull())
  97. itemsObject.itemShortTitle = valueItemsItemInfo["ItemShortTitle"].asString();
  98. if(!valueItemsItemInfo["Material"].isNull())
  99. itemsObject.material = valueItemsItemInfo["Material"].asString();
  100. if(!valueItemsItemInfo["BePromotion"].isNull())
  101. itemsObject.bePromotion = valueItemsItemInfo["BePromotion"].asString() == "true";
  102. if(!valueItemsItemInfo["ForestSecondId"].isNull())
  103. itemsObject.forestSecondId = valueItemsItemInfo["ForestSecondId"].asString();
  104. if(!valueItemsItemInfo["BeSourceCode"].isNull())
  105. itemsObject.beSourceCode = valueItemsItemInfo["BeSourceCode"].asString() == "true";
  106. if(!valueItemsItemInfo["SalesPrice"].isNull())
  107. itemsObject.salesPrice = std::stoi(valueItemsItemInfo["SalesPrice"].asString());
  108. if(!valueItemsItemInfo["ItemPicUrl"].isNull())
  109. itemsObject.itemPicUrl = valueItemsItemInfo["ItemPicUrl"].asString();
  110. if(!valueItemsItemInfo["SkuId"].isNull())
  111. itemsObject.skuId = valueItemsItemInfo["SkuId"].asString();
  112. if(!valueItemsItemInfo["SuggestPrice"].isNull())
  113. itemsObject.suggestPrice = std::stoi(valueItemsItemInfo["SuggestPrice"].asString());
  114. if(!valueItemsItemInfo["Rank"].isNull())
  115. itemsObject.rank = valueItemsItemInfo["Rank"].asString();
  116. if(!valueItemsItemInfo["SourceCode"].isNull())
  117. itemsObject.sourceCode = valueItemsItemInfo["SourceCode"].asString();
  118. if(!valueItemsItemInfo["ProductionPlace"].isNull())
  119. itemsObject.productionPlace = valueItemsItemInfo["ProductionPlace"].asString();
  120. if(!valueItemsItemInfo["ItemInfoIndex"].isNull())
  121. itemsObject.itemInfoIndex = std::stoi(valueItemsItemInfo["ItemInfoIndex"].asString());
  122. if(!valueItemsItemInfo["InventoryStatus"].isNull())
  123. itemsObject.inventoryStatus = valueItemsItemInfo["InventoryStatus"].asString();
  124. if(!valueItemsItemInfo["PriceUnit"].isNull())
  125. itemsObject.priceUnit = valueItemsItemInfo["PriceUnit"].asString();
  126. if(!valueItemsItemInfo["ActionPrice"].isNull())
  127. itemsObject.actionPrice = std::stoi(valueItemsItemInfo["ActionPrice"].asString());
  128. if(!valueItemsItemInfo["BrandName"].isNull())
  129. itemsObject.brandName = valueItemsItemInfo["BrandName"].asString();
  130. if(!valueItemsItemInfo["ItemQrCode"].isNull())
  131. itemsObject.itemQrCode = valueItemsItemInfo["ItemQrCode"].asString();
  132. if(!valueItemsItemInfo["PromotionReason"].isNull())
  133. itemsObject.promotionReason = valueItemsItemInfo["PromotionReason"].asString();
  134. if(!valueItemsItemInfo["ItemBarCode"].isNull())
  135. itemsObject.itemBarCode = valueItemsItemInfo["ItemBarCode"].asString();
  136. if(!valueItemsItemInfo["ItemId"].isNull())
  137. itemsObject.itemId = valueItemsItemInfo["ItemId"].asString();
  138. if(!valueItemsItemInfo["PromotionStart"].isNull())
  139. itemsObject.promotionStart = valueItemsItemInfo["PromotionStart"].asString();
  140. items_.push_back(itemsObject);
  141. }
  142. if(!value["ErrorMessage"].isNull())
  143. errorMessage_ = value["ErrorMessage"].asString();
  144. if(!value["ErrorCode"].isNull())
  145. errorCode_ = value["ErrorCode"].asString();
  146. if(!value["PageNumber"].isNull())
  147. pageNumber_ = std::stoi(value["PageNumber"].asString());
  148. if(!value["Message"].isNull())
  149. message_ = value["Message"].asString();
  150. if(!value["PageSize"].isNull())
  151. pageSize_ = std::stoi(value["PageSize"].asString());
  152. if(!value["DynamicCode"].isNull())
  153. dynamicCode_ = value["DynamicCode"].asString();
  154. if(!value["Code"].isNull())
  155. code_ = value["Code"].asString();
  156. if(!value["DynamicMessage"].isNull())
  157. dynamicMessage_ = value["DynamicMessage"].asString();
  158. if(!value["TotalCount"].isNull())
  159. totalCount_ = std::stoi(value["TotalCount"].asString());
  160. if(!value["Success"].isNull())
  161. success_ = value["Success"].asString() == "true";
  162. }
  163. int DescribeItemsResult::getTotalCount()const
  164. {
  165. return totalCount_;
  166. }
  167. std::string DescribeItemsResult::getMessage()const
  168. {
  169. return message_;
  170. }
  171. int DescribeItemsResult::getPageSize()const
  172. {
  173. return pageSize_;
  174. }
  175. int DescribeItemsResult::getPageNumber()const
  176. {
  177. return pageNumber_;
  178. }
  179. std::vector<DescribeItemsResult::ItemInfo> DescribeItemsResult::getItems()const
  180. {
  181. return items_;
  182. }
  183. std::string DescribeItemsResult::getDynamicCode()const
  184. {
  185. return dynamicCode_;
  186. }
  187. std::string DescribeItemsResult::getErrorCode()const
  188. {
  189. return errorCode_;
  190. }
  191. std::string DescribeItemsResult::getDynamicMessage()const
  192. {
  193. return dynamicMessage_;
  194. }
  195. std::string DescribeItemsResult::getErrorMessage()const
  196. {
  197. return errorMessage_;
  198. }
  199. std::string DescribeItemsResult::getCode()const
  200. {
  201. return code_;
  202. }
  203. bool DescribeItemsResult::getSuccess()const
  204. {
  205. return success_;
  206. }