CreateAlbumResult.cc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/cloudphoto/model/CreateAlbumResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CloudPhoto;
  19. using namespace AlibabaCloud::CloudPhoto::Model;
  20. CreateAlbumResult::CreateAlbumResult() :
  21. ServiceResult()
  22. {}
  23. CreateAlbumResult::CreateAlbumResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreateAlbumResult::~CreateAlbumResult()
  29. {}
  30. void CreateAlbumResult::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 albumNode = value["Album"];
  37. if(!albumNode["Id"].isNull())
  38. album_.id = std::stol(albumNode["Id"].asString());
  39. if(!albumNode["IdStr"].isNull())
  40. album_.idStr = albumNode["IdStr"].asString();
  41. if(!albumNode["Name"].isNull())
  42. album_.name = albumNode["Name"].asString();
  43. if(!albumNode["State"].isNull())
  44. album_.state = albumNode["State"].asString();
  45. if(!albumNode["Remark"].isNull())
  46. album_.remark = albumNode["Remark"].asString();
  47. if(!albumNode["PhotosCount"].isNull())
  48. album_.photosCount = std::stol(albumNode["PhotosCount"].asString());
  49. if(!albumNode["Ctime"].isNull())
  50. album_.ctime = std::stol(albumNode["Ctime"].asString());
  51. if(!albumNode["Mtime"].isNull())
  52. album_.mtime = std::stol(albumNode["Mtime"].asString());
  53. auto coverNode = albumNode["Cover"];
  54. if(!coverNode["Id"].isNull())
  55. album_.cover.id = std::stol(coverNode["Id"].asString());
  56. if(!coverNode["IdStr"].isNull())
  57. album_.cover.idStr = coverNode["IdStr"].asString();
  58. if(!coverNode["Title"].isNull())
  59. album_.cover.title = coverNode["Title"].asString();
  60. if(!coverNode["FileId"].isNull())
  61. album_.cover.fileId = coverNode["FileId"].asString();
  62. if(!coverNode["State"].isNull())
  63. album_.cover.state = coverNode["State"].asString();
  64. if(!coverNode["Md5"].isNull())
  65. album_.cover.md5 = coverNode["Md5"].asString();
  66. if(!coverNode["IsVideo"].isNull())
  67. album_.cover.isVideo = coverNode["IsVideo"].asString() == "true";
  68. if(!coverNode["Width"].isNull())
  69. album_.cover.width = std::stol(coverNode["Width"].asString());
  70. if(!coverNode["Height"].isNull())
  71. album_.cover.height = std::stol(coverNode["Height"].asString());
  72. if(!coverNode["Ctime"].isNull())
  73. album_.cover.ctime = std::stol(coverNode["Ctime"].asString());
  74. if(!coverNode["Mtime"].isNull())
  75. album_.cover.mtime = std::stol(coverNode["Mtime"].asString());
  76. if(!coverNode["Remark"].isNull())
  77. album_.cover.remark = coverNode["Remark"].asString();
  78. if(!value["Code"].isNull())
  79. code_ = value["Code"].asString();
  80. if(!value["Message"].isNull())
  81. message_ = value["Message"].asString();
  82. if(!value["Action"].isNull())
  83. action_ = value["Action"].asString();
  84. }
  85. std::string CreateAlbumResult::getAction()const
  86. {
  87. return action_;
  88. }
  89. std::string CreateAlbumResult::getMessage()const
  90. {
  91. return message_;
  92. }
  93. CreateAlbumResult::Album CreateAlbumResult::getAlbum()const
  94. {
  95. return album_;
  96. }
  97. std::string CreateAlbumResult::getCode()const
  98. {
  99. return code_;
  100. }