DescribeUsageBillResult.cc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/green/model/DescribeUsageBillResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Green;
  19. using namespace AlibabaCloud::Green::Model;
  20. DescribeUsageBillResult::DescribeUsageBillResult() :
  21. ServiceResult()
  22. {}
  23. DescribeUsageBillResult::DescribeUsageBillResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. DescribeUsageBillResult::~DescribeUsageBillResult()
  29. {}
  30. void DescribeUsageBillResult::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 allBillListNode = value["BillList"]["Bill"];
  37. for (auto valueBillListBill : allBillListNode)
  38. {
  39. Bill billListObject;
  40. if(!valueBillListBill["Region"].isNull())
  41. billListObject.region = valueBillListBill["Region"].asString();
  42. if(!valueBillListBill["Scene"].isNull())
  43. billListObject.scene = valueBillListBill["Scene"].asString();
  44. if(!valueBillListBill["TotalCount"].isNull())
  45. billListObject.totalCount = std::stol(valueBillListBill["TotalCount"].asString());
  46. if(!valueBillListBill["ConfirmCount"].isNull())
  47. billListObject.confirmCount = std::stol(valueBillListBill["ConfirmCount"].asString());
  48. if(!valueBillListBill["ReviewCount"].isNull())
  49. billListObject.reviewCount = std::stol(valueBillListBill["ReviewCount"].asString());
  50. if(!valueBillListBill["FreeCount"].isNull())
  51. billListObject.freeCount = std::stol(valueBillListBill["FreeCount"].asString());
  52. if(!valueBillListBill["SubUid"].isNull())
  53. billListObject.subUid = valueBillListBill["SubUid"].asString();
  54. if(!valueBillListBill["BizType"].isNull())
  55. billListObject.bizType = valueBillListBill["BizType"].asString();
  56. if(!valueBillListBill["Day"].isNull())
  57. billListObject.day = valueBillListBill["Day"].asString();
  58. billList_.push_back(billListObject);
  59. }
  60. if(!value["TotalCount"].isNull())
  61. totalCount_ = std::stoi(value["TotalCount"].asString());
  62. if(!value["PageSize"].isNull())
  63. pageSize_ = std::stoi(value["PageSize"].asString());
  64. if(!value["CurrentPage"].isNull())
  65. currentPage_ = std::stoi(value["CurrentPage"].asString());
  66. }
  67. int DescribeUsageBillResult::getTotalCount()const
  68. {
  69. return totalCount_;
  70. }
  71. int DescribeUsageBillResult::getPageSize()const
  72. {
  73. return pageSize_;
  74. }
  75. int DescribeUsageBillResult::getCurrentPage()const
  76. {
  77. return currentPage_;
  78. }
  79. std::vector<DescribeUsageBillResult::Bill> DescribeUsageBillResult::getBillList()const
  80. {
  81. return billList_;
  82. }