QueryInstanceGaapCostResult.cc 8.5 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 allModules = value["Modules"]["Module"];
  46. for (auto value : allModules)
  47. {
  48. Data::Module moduleObject;
  49. if(!value["BillingCycle"].isNull())
  50. moduleObject.billingCycle = value["BillingCycle"].asString();
  51. if(!value["InstanceID"].isNull())
  52. moduleObject.instanceID = value["InstanceID"].asString();
  53. if(!value["ProductCode"].isNull())
  54. moduleObject.productCode = value["ProductCode"].asString();
  55. if(!value["ProductType"].isNull())
  56. moduleObject.productType = value["ProductType"].asString();
  57. if(!value["SubscriptionType"].isNull())
  58. moduleObject.subscriptionType = value["SubscriptionType"].asString();
  59. if(!value["Tag"].isNull())
  60. moduleObject.tag = value["Tag"].asString();
  61. if(!value["ResourceGroup"].isNull())
  62. moduleObject.resourceGroup = value["ResourceGroup"].asString();
  63. if(!value["AccountingUnit"].isNull())
  64. moduleObject.accountingUnit = value["AccountingUnit"].asString();
  65. if(!value["PayerAccount"].isNull())
  66. moduleObject.payerAccount = value["PayerAccount"].asString();
  67. if(!value["OwnerID"].isNull())
  68. moduleObject.ownerID = value["OwnerID"].asString();
  69. if(!value["Region"].isNull())
  70. moduleObject.region = value["Region"].asString();
  71. if(!value["Currency"].isNull())
  72. moduleObject.currency = value["Currency"].asString();
  73. if(!value["PaymentCurrency"].isNull())
  74. moduleObject.paymentCurrency = value["PaymentCurrency"].asString();
  75. if(!value["OrderType"].isNull())
  76. moduleObject.orderType = value["OrderType"].asString();
  77. if(!value["PayTime"].isNull())
  78. moduleObject.payTime = value["PayTime"].asString();
  79. if(!value["PretaxGrossAmount"].isNull())
  80. moduleObject.pretaxGrossAmount = value["PretaxGrossAmount"].asString();
  81. if(!value["PricingDiscount"].isNull())
  82. moduleObject.pricingDiscount = value["PricingDiscount"].asString();
  83. if(!value["DeductedByCoupons"].isNull())
  84. moduleObject.deductedByCoupons = value["DeductedByCoupons"].asString();
  85. if(!value["PretaxAmount"].isNull())
  86. moduleObject.pretaxAmount = value["PretaxAmount"].asString();
  87. if(!value["PretaxAmountLocal"].isNull())
  88. moduleObject.pretaxAmountLocal = value["PretaxAmountLocal"].asString();
  89. if(!value["DeductedByCashCoupons"].isNull())
  90. moduleObject.deductedByCashCoupons = value["DeductedByCashCoupons"].asString();
  91. if(!value["DeductedByPrepaidCard"].isNull())
  92. moduleObject.deductedByPrepaidCard = value["DeductedByPrepaidCard"].asString();
  93. if(!value["PaymentAmount"].isNull())
  94. moduleObject.paymentAmount = value["PaymentAmount"].asString();
  95. if(!value["GaapPretaxGrossAmount"].isNull())
  96. moduleObject.gaapPretaxGrossAmount = value["GaapPretaxGrossAmount"].asString();
  97. if(!value["GaapPricingDiscount"].isNull())
  98. moduleObject.gaapPricingDiscount = value["GaapPricingDiscount"].asString();
  99. if(!value["GaapDeductedByCoupons"].isNull())
  100. moduleObject.gaapDeductedByCoupons = value["GaapDeductedByCoupons"].asString();
  101. if(!value["GaapPretaxAmount"].isNull())
  102. moduleObject.gaapPretaxAmount = value["GaapPretaxAmount"].asString();
  103. if(!value["GaapPretaxAmountLocal"].isNull())
  104. moduleObject.gaapPretaxAmountLocal = value["GaapPretaxAmountLocal"].asString();
  105. if(!value["GaapDeductedByCashCoupons"].isNull())
  106. moduleObject.gaapDeductedByCashCoupons = value["GaapDeductedByCashCoupons"].asString();
  107. if(!value["GaapDeductedByPrepaidCard"].isNull())
  108. moduleObject.gaapDeductedByPrepaidCard = value["GaapDeductedByPrepaidCard"].asString();
  109. if(!value["GaapPaymentAmount"].isNull())
  110. moduleObject.gaapPaymentAmount = value["GaapPaymentAmount"].asString();
  111. if(!value["MonthGaapPretaxGrossAmount"].isNull())
  112. moduleObject.monthGaapPretaxGrossAmount = value["MonthGaapPretaxGrossAmount"].asString();
  113. if(!value["MonthGaapPricingDiscount"].isNull())
  114. moduleObject.monthGaapPricingDiscount = value["MonthGaapPricingDiscount"].asString();
  115. if(!value["MonthGaapDeductedByCoupons"].isNull())
  116. moduleObject.monthGaapDeductedByCoupons = value["MonthGaapDeductedByCoupons"].asString();
  117. if(!value["MonthGaapPretaxAmount"].isNull())
  118. moduleObject.monthGaapPretaxAmount = value["MonthGaapPretaxAmount"].asString();
  119. if(!value["MonthGaapPretaxAmountLocal"].isNull())
  120. moduleObject.monthGaapPretaxAmountLocal = value["MonthGaapPretaxAmountLocal"].asString();
  121. if(!value["MonthGaapDeductedByCashCoupons"].isNull())
  122. moduleObject.monthGaapDeductedByCashCoupons = value["MonthGaapDeductedByCashCoupons"].asString();
  123. if(!value["MonthGaapDeductedByPrepaidCard"].isNull())
  124. moduleObject.monthGaapDeductedByPrepaidCard = value["MonthGaapDeductedByPrepaidCard"].asString();
  125. if(!value["MonthGaapPaymentAmount"].isNull())
  126. moduleObject.monthGaapPaymentAmount = value["MonthGaapPaymentAmount"].asString();
  127. if(!value["UnallocatedPaymentAmount"].isNull())
  128. moduleObject.unallocatedPaymentAmount = value["UnallocatedPaymentAmount"].asString();
  129. if(!value["UsageStartDate"].isNull())
  130. moduleObject.usageStartDate = value["UsageStartDate"].asString();
  131. if(!value["UsageEndDate"].isNull())
  132. moduleObject.usageEndDate = value["UsageEndDate"].asString();
  133. if(!value["BillType"].isNull())
  134. moduleObject.billType = value["BillType"].asString();
  135. if(!value["OrderId"].isNull())
  136. moduleObject.orderId = value["OrderId"].asString();
  137. if(!value["SubOrderId"].isNull())
  138. moduleObject.subOrderId = value["SubOrderId"].asString();
  139. if(!value["UnallocatedPretaxGrossAmount"].isNull())
  140. moduleObject.unallocatedPretaxGrossAmount = value["UnallocatedPretaxGrossAmount"].asString();
  141. if(!value["UnallocatedPricingDiscount"].isNull())
  142. moduleObject.unallocatedPricingDiscount = value["UnallocatedPricingDiscount"].asString();
  143. if(!value["UnallocatedDeductedByCoupons"].isNull())
  144. moduleObject.unallocatedDeductedByCoupons = value["UnallocatedDeductedByCoupons"].asString();
  145. if(!value["UnallocatedPretaxAmount"].isNull())
  146. moduleObject.unallocatedPretaxAmount = value["UnallocatedPretaxAmount"].asString();
  147. if(!value["UnallocatedPretaxAmountLocal"].isNull())
  148. moduleObject.unallocatedPretaxAmountLocal = value["UnallocatedPretaxAmountLocal"].asString();
  149. if(!value["UnallocatedDeductedByCashCoupons"].isNull())
  150. moduleObject.unallocatedDeductedByCashCoupons = value["UnallocatedDeductedByCashCoupons"].asString();
  151. if(!value["UnallocatedDeductedByPrepaidCard"].isNull())
  152. moduleObject.unallocatedDeductedByPrepaidCard = value["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. }