QueryBillOverviewResult.cc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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/QueryBillOverviewResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::BssOpenApi;
  19. using namespace AlibabaCloud::BssOpenApi::Model;
  20. QueryBillOverviewResult::QueryBillOverviewResult() :
  21. ServiceResult()
  22. {}
  23. QueryBillOverviewResult::QueryBillOverviewResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. QueryBillOverviewResult::~QueryBillOverviewResult()
  29. {}
  30. void QueryBillOverviewResult::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["BillingCycle"].isNull())
  38. data_.billingCycle = dataNode["BillingCycle"].asString();
  39. if(!dataNode["AccountID"].isNull())
  40. data_.accountID = dataNode["AccountID"].asString();
  41. if(!dataNode["AccountName"].isNull())
  42. data_.accountName = dataNode["AccountName"].asString();
  43. auto allItemsNode = dataNode["Items"]["Item"];
  44. for (auto dataNodeItemsItem : allItemsNode)
  45. {
  46. Data::Item itemObject;
  47. if(!dataNodeItemsItem["Item"].isNull())
  48. itemObject.item = dataNodeItemsItem["Item"].asString();
  49. if(!dataNodeItemsItem["ProductCode"].isNull())
  50. itemObject.productCode = dataNodeItemsItem["ProductCode"].asString();
  51. if(!dataNodeItemsItem["ProductType"].isNull())
  52. itemObject.productType = dataNodeItemsItem["ProductType"].asString();
  53. if(!dataNodeItemsItem["SubscriptionType"].isNull())
  54. itemObject.subscriptionType = dataNodeItemsItem["SubscriptionType"].asString();
  55. if(!dataNodeItemsItem["ProductName"].isNull())
  56. itemObject.productName = dataNodeItemsItem["ProductName"].asString();
  57. if(!dataNodeItemsItem["ProductDetail"].isNull())
  58. itemObject.productDetail = dataNodeItemsItem["ProductDetail"].asString();
  59. if(!dataNodeItemsItem["PretaxGrossAmount"].isNull())
  60. itemObject.pretaxGrossAmount = std::stof(dataNodeItemsItem["PretaxGrossAmount"].asString());
  61. if(!dataNodeItemsItem["InvoiceDiscount"].isNull())
  62. itemObject.invoiceDiscount = std::stof(dataNodeItemsItem["InvoiceDiscount"].asString());
  63. if(!dataNodeItemsItem["DeductedByCoupons"].isNull())
  64. itemObject.deductedByCoupons = std::stof(dataNodeItemsItem["DeductedByCoupons"].asString());
  65. if(!dataNodeItemsItem["PretaxAmount"].isNull())
  66. itemObject.pretaxAmount = std::stof(dataNodeItemsItem["PretaxAmount"].asString());
  67. if(!dataNodeItemsItem["Currency"].isNull())
  68. itemObject.currency = dataNodeItemsItem["Currency"].asString();
  69. if(!dataNodeItemsItem["PaymentAmount"].isNull())
  70. itemObject.paymentAmount = std::stof(dataNodeItemsItem["PaymentAmount"].asString());
  71. if(!dataNodeItemsItem["OutstandingAmount"].isNull())
  72. itemObject.outstandingAmount = std::stof(dataNodeItemsItem["OutstandingAmount"].asString());
  73. if(!dataNodeItemsItem["DeductedByCashCoupons"].isNull())
  74. itemObject.deductedByCashCoupons = std::stof(dataNodeItemsItem["DeductedByCashCoupons"].asString());
  75. if(!dataNodeItemsItem["DeductedByPrepaidCard"].isNull())
  76. itemObject.deductedByPrepaidCard = std::stof(dataNodeItemsItem["DeductedByPrepaidCard"].asString());
  77. if(!dataNodeItemsItem["PretaxAmountLocal"].isNull())
  78. itemObject.pretaxAmountLocal = std::stof(dataNodeItemsItem["PretaxAmountLocal"].asString());
  79. if(!dataNodeItemsItem["Tax"].isNull())
  80. itemObject.tax = std::stof(dataNodeItemsItem["Tax"].asString());
  81. if(!dataNodeItemsItem["AfterTaxAmount"].isNull())
  82. itemObject.afterTaxAmount = std::stof(dataNodeItemsItem["AfterTaxAmount"].asString());
  83. if(!dataNodeItemsItem["PaymentCurrency"].isNull())
  84. itemObject.paymentCurrency = dataNodeItemsItem["PaymentCurrency"].asString();
  85. if(!dataNodeItemsItem["RoundDownDiscount"].isNull())
  86. itemObject.roundDownDiscount = dataNodeItemsItem["RoundDownDiscount"].asString();
  87. if(!dataNodeItemsItem["PipCode"].isNull())
  88. itemObject.pipCode = dataNodeItemsItem["PipCode"].asString();
  89. if(!dataNodeItemsItem["CommodityCode"].isNull())
  90. itemObject.commodityCode = dataNodeItemsItem["CommodityCode"].asString();
  91. data_.items.push_back(itemObject);
  92. }
  93. if(!value["Success"].isNull())
  94. success_ = value["Success"].asString() == "true";
  95. if(!value["Code"].isNull())
  96. code_ = value["Code"].asString();
  97. if(!value["Message"].isNull())
  98. message_ = value["Message"].asString();
  99. }
  100. std::string QueryBillOverviewResult::getMessage()const
  101. {
  102. return message_;
  103. }
  104. QueryBillOverviewResult::Data QueryBillOverviewResult::getData()const
  105. {
  106. return data_;
  107. }
  108. std::string QueryBillOverviewResult::getCode()const
  109. {
  110. return code_;
  111. }
  112. bool QueryBillOverviewResult::getSuccess()const
  113. {
  114. return success_;
  115. }