QueryInstanceGaapCostResult.cc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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/QueryInstanceGaapCostResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::BssOpenApi;
  19. using namespace AlibabaCloud::BssOpenApi::Model;
  20. QueryInstanceGaapCostResult::QueryInstanceGaapCostResult() :
  21. ServiceResult()
  22. {}
  23. QueryInstanceGaapCostResult::QueryInstanceGaapCostResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryInstanceGaapCostResult::~QueryInstanceGaapCostResult()
  29. {}
  30. void QueryInstanceGaapCostResult::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["HostId"].isNull())
  38. data_.hostId = dataNode["HostId"].asString();
  39. if(!dataNode["PageNum"].isNull())
  40. data_.pageNum = std::stoi(dataNode["PageNum"].asString());
  41. if(!dataNode["PageSize"].isNull())
  42. data_.pageSize = std::stoi(dataNode["PageSize"].asString());
  43. if(!dataNode["TotalCount"].isNull())
  44. data_.totalCount = std::stoi(dataNode["TotalCount"].asString());
  45. auto allModulesNode = dataNode["Modules"]["Module"];
  46. for (auto dataNodeModulesModule : allModulesNode)
  47. {
  48. Data::Module moduleObject;
  49. if(!dataNodeModulesModule["BillingCycle"].isNull())
  50. moduleObject.billingCycle = dataNodeModulesModule["BillingCycle"].asString();
  51. if(!dataNodeModulesModule["InstanceID"].isNull())
  52. moduleObject.instanceID = dataNodeModulesModule["InstanceID"].asString();
  53. if(!dataNodeModulesModule["ProductCode"].isNull())
  54. moduleObject.productCode = dataNodeModulesModule["ProductCode"].asString();
  55. if(!dataNodeModulesModule["ProductType"].isNull())
  56. moduleObject.productType = dataNodeModulesModule["ProductType"].asString();
  57. if(!dataNodeModulesModule["SubscriptionType"].isNull())
  58. moduleObject.subscriptionType = dataNodeModulesModule["SubscriptionType"].asString();
  59. if(!dataNodeModulesModule["Tag"].isNull())
  60. moduleObject.tag = dataNodeModulesModule["Tag"].asString();
  61. if(!dataNodeModulesModule["ResourceGroup"].isNull())
  62. moduleObject.resourceGroup = dataNodeModulesModule["ResourceGroup"].asString();
  63. if(!dataNodeModulesModule["AccountingUnit"].isNull())
  64. moduleObject.accountingUnit = dataNodeModulesModule["AccountingUnit"].asString();
  65. if(!dataNodeModulesModule["PayerAccount"].isNull())
  66. moduleObject.payerAccount = dataNodeModulesModule["PayerAccount"].asString();
  67. if(!dataNodeModulesModule["OwnerID"].isNull())
  68. moduleObject.ownerID = dataNodeModulesModule["OwnerID"].asString();
  69. if(!dataNodeModulesModule["Region"].isNull())
  70. moduleObject.region = dataNodeModulesModule["Region"].asString();
  71. if(!dataNodeModulesModule["Currency"].isNull())
  72. moduleObject.currency = dataNodeModulesModule["Currency"].asString();
  73. if(!dataNodeModulesModule["PaymentCurrency"].isNull())
  74. moduleObject.paymentCurrency = dataNodeModulesModule["PaymentCurrency"].asString();
  75. if(!dataNodeModulesModule["OrderType"].isNull())
  76. moduleObject.orderType = dataNodeModulesModule["OrderType"].asString();
  77. if(!dataNodeModulesModule["PayTime"].isNull())
  78. moduleObject.payTime = dataNodeModulesModule["PayTime"].asString();
  79. if(!dataNodeModulesModule["PretaxGrossAmount"].isNull())
  80. moduleObject.pretaxGrossAmount = dataNodeModulesModule["PretaxGrossAmount"].asString();
  81. if(!dataNodeModulesModule["PricingDiscount"].isNull())
  82. moduleObject.pricingDiscount = dataNodeModulesModule["PricingDiscount"].asString();
  83. if(!dataNodeModulesModule["DeductedByCoupons"].isNull())
  84. moduleObject.deductedByCoupons = dataNodeModulesModule["DeductedByCoupons"].asString();
  85. if(!dataNodeModulesModule["PretaxAmount"].isNull())
  86. moduleObject.pretaxAmount = dataNodeModulesModule["PretaxAmount"].asString();
  87. if(!dataNodeModulesModule["PretaxAmountLocal"].isNull())
  88. moduleObject.pretaxAmountLocal = dataNodeModulesModule["PretaxAmountLocal"].asString();
  89. if(!dataNodeModulesModule["DeductedByCashCoupons"].isNull())
  90. moduleObject.deductedByCashCoupons = dataNodeModulesModule["DeductedByCashCoupons"].asString();
  91. if(!dataNodeModulesModule["DeductedByPrepaidCard"].isNull())
  92. moduleObject.deductedByPrepaidCard = dataNodeModulesModule["DeductedByPrepaidCard"].asString();
  93. if(!dataNodeModulesModule["PaymentAmount"].isNull())
  94. moduleObject.paymentAmount = dataNodeModulesModule["PaymentAmount"].asString();
  95. if(!dataNodeModulesModule["GaapPretaxGrossAmount"].isNull())
  96. moduleObject.gaapPretaxGrossAmount = dataNodeModulesModule["GaapPretaxGrossAmount"].asString();
  97. if(!dataNodeModulesModule["GaapPricingDiscount"].isNull())
  98. moduleObject.gaapPricingDiscount = dataNodeModulesModule["GaapPricingDiscount"].asString();
  99. if(!dataNodeModulesModule["GaapDeductedByCoupons"].isNull())
  100. moduleObject.gaapDeductedByCoupons = dataNodeModulesModule["GaapDeductedByCoupons"].asString();
  101. if(!dataNodeModulesModule["GaapPretaxAmount"].isNull())
  102. moduleObject.gaapPretaxAmount = dataNodeModulesModule["GaapPretaxAmount"].asString();
  103. if(!dataNodeModulesModule["GaapPretaxAmountLocal"].isNull())
  104. moduleObject.gaapPretaxAmountLocal = dataNodeModulesModule["GaapPretaxAmountLocal"].asString();
  105. if(!dataNodeModulesModule["GaapDeductedByCashCoupons"].isNull())
  106. moduleObject.gaapDeductedByCashCoupons = dataNodeModulesModule["GaapDeductedByCashCoupons"].asString();
  107. if(!dataNodeModulesModule["GaapDeductedByPrepaidCard"].isNull())
  108. moduleObject.gaapDeductedByPrepaidCard = dataNodeModulesModule["GaapDeductedByPrepaidCard"].asString();
  109. if(!dataNodeModulesModule["GaapPaymentAmount"].isNull())
  110. moduleObject.gaapPaymentAmount = dataNodeModulesModule["GaapPaymentAmount"].asString();
  111. if(!dataNodeModulesModule["MonthGaapPretaxGrossAmount"].isNull())
  112. moduleObject.monthGaapPretaxGrossAmount = dataNodeModulesModule["MonthGaapPretaxGrossAmount"].asString();
  113. if(!dataNodeModulesModule["MonthGaapPricingDiscount"].isNull())
  114. moduleObject.monthGaapPricingDiscount = dataNodeModulesModule["MonthGaapPricingDiscount"].asString();
  115. if(!dataNodeModulesModule["MonthGaapDeductedByCoupons"].isNull())
  116. moduleObject.monthGaapDeductedByCoupons = dataNodeModulesModule["MonthGaapDeductedByCoupons"].asString();
  117. if(!dataNodeModulesModule["MonthGaapPretaxAmount"].isNull())
  118. moduleObject.monthGaapPretaxAmount = dataNodeModulesModule["MonthGaapPretaxAmount"].asString();
  119. if(!dataNodeModulesModule["MonthGaapPretaxAmountLocal"].isNull())
  120. moduleObject.monthGaapPretaxAmountLocal = dataNodeModulesModule["MonthGaapPretaxAmountLocal"].asString();
  121. if(!dataNodeModulesModule["MonthGaapDeductedByCashCoupons"].isNull())
  122. moduleObject.monthGaapDeductedByCashCoupons = dataNodeModulesModule["MonthGaapDeductedByCashCoupons"].asString();
  123. if(!dataNodeModulesModule["MonthGaapDeductedByPrepaidCard"].isNull())
  124. moduleObject.monthGaapDeductedByPrepaidCard = dataNodeModulesModule["MonthGaapDeductedByPrepaidCard"].asString();
  125. if(!dataNodeModulesModule["MonthGaapPaymentAmount"].isNull())
  126. moduleObject.monthGaapPaymentAmount = dataNodeModulesModule["MonthGaapPaymentAmount"].asString();
  127. if(!dataNodeModulesModule["UnallocatedPaymentAmount"].isNull())
  128. moduleObject.unallocatedPaymentAmount = dataNodeModulesModule["UnallocatedPaymentAmount"].asString();
  129. if(!dataNodeModulesModule["UsageStartDate"].isNull())
  130. moduleObject.usageStartDate = dataNodeModulesModule["UsageStartDate"].asString();
  131. if(!dataNodeModulesModule["UsageEndDate"].isNull())
  132. moduleObject.usageEndDate = dataNodeModulesModule["UsageEndDate"].asString();
  133. if(!dataNodeModulesModule["BillType"].isNull())
  134. moduleObject.billType = dataNodeModulesModule["BillType"].asString();
  135. if(!dataNodeModulesModule["OrderId"].isNull())
  136. moduleObject.orderId = dataNodeModulesModule["OrderId"].asString();
  137. if(!dataNodeModulesModule["SubOrderId"].isNull())
  138. moduleObject.subOrderId = dataNodeModulesModule["SubOrderId"].asString();
  139. if(!dataNodeModulesModule["UnallocatedPretaxGrossAmount"].isNull())
  140. moduleObject.unallocatedPretaxGrossAmount = dataNodeModulesModule["UnallocatedPretaxGrossAmount"].asString();
  141. if(!dataNodeModulesModule["UnallocatedPricingDiscount"].isNull())
  142. moduleObject.unallocatedPricingDiscount = dataNodeModulesModule["UnallocatedPricingDiscount"].asString();
  143. if(!dataNodeModulesModule["UnallocatedDeductedByCoupons"].isNull())
  144. moduleObject.unallocatedDeductedByCoupons = dataNodeModulesModule["UnallocatedDeductedByCoupons"].asString();
  145. if(!dataNodeModulesModule["UnallocatedPretaxAmount"].isNull())
  146. moduleObject.unallocatedPretaxAmount = dataNodeModulesModule["UnallocatedPretaxAmount"].asString();
  147. if(!dataNodeModulesModule["UnallocatedPretaxAmountLocal"].isNull())
  148. moduleObject.unallocatedPretaxAmountLocal = dataNodeModulesModule["UnallocatedPretaxAmountLocal"].asString();
  149. if(!dataNodeModulesModule["UnallocatedDeductedByCashCoupons"].isNull())
  150. moduleObject.unallocatedDeductedByCashCoupons = dataNodeModulesModule["UnallocatedDeductedByCashCoupons"].asString();
  151. if(!dataNodeModulesModule["UnallocatedDeductedByPrepaidCard"].isNull())
  152. moduleObject.unallocatedDeductedByPrepaidCard = dataNodeModulesModule["UnallocatedDeductedByPrepaidCard"].asString();
  153. data_.modules.push_back(moduleObject);
  154. }
  155. if(!value["Success"].isNull())
  156. success_ = value["Success"].asString() == "true";
  157. if(!value["Code"].isNull())
  158. code_ = value["Code"].asString();
  159. if(!value["Message"].isNull())
  160. message_ = value["Message"].asString();
  161. }
  162. std::string QueryInstanceGaapCostResult::getMessage()const
  163. {
  164. return message_;
  165. }
  166. QueryInstanceGaapCostResult::Data QueryInstanceGaapCostResult::getData()const
  167. {
  168. return data_;
  169. }
  170. std::string QueryInstanceGaapCostResult::getCode()const
  171. {
  172. return code_;
  173. }
  174. bool QueryInstanceGaapCostResult::getSuccess()const
  175. {
  176. return success_;
  177. }