CreatePhotoResult.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/CreatePhotoResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CloudPhoto;
  19. using namespace AlibabaCloud::CloudPhoto::Model;
  20. CreatePhotoResult::CreatePhotoResult() :
  21. ServiceResult()
  22. {}
  23. CreatePhotoResult::CreatePhotoResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. CreatePhotoResult::~CreatePhotoResult()
  29. {}
  30. void CreatePhotoResult::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 photoNode = value["Photo"];
  37. if(!photoNode["Id"].isNull())
  38. photo_.id = std::stol(photoNode["Id"].asString());
  39. if(!photoNode["IdStr"].isNull())
  40. photo_.idStr = photoNode["IdStr"].asString();
  41. if(!photoNode["Title"].isNull())
  42. photo_.title = photoNode["Title"].asString();
  43. if(!photoNode["FileId"].isNull())
  44. photo_.fileId = photoNode["FileId"].asString();
  45. if(!photoNode["Location"].isNull())
  46. photo_.location = photoNode["Location"].asString();
  47. if(!photoNode["State"].isNull())
  48. photo_.state = photoNode["State"].asString();
  49. if(!photoNode["Md5"].isNull())
  50. photo_.md5 = photoNode["Md5"].asString();
  51. if(!photoNode["IsVideo"].isNull())
  52. photo_.isVideo = photoNode["IsVideo"].asString() == "true";
  53. if(!photoNode["Size"].isNull())
  54. photo_.size = std::stol(photoNode["Size"].asString());
  55. if(!photoNode["Remark"].isNull())
  56. photo_.remark = photoNode["Remark"].asString();
  57. if(!photoNode["Width"].isNull())
  58. photo_.width = std::stol(photoNode["Width"].asString());
  59. if(!photoNode["Height"].isNull())
  60. photo_.height = std::stol(photoNode["Height"].asString());
  61. if(!photoNode["Ctime"].isNull())
  62. photo_.ctime = std::stol(photoNode["Ctime"].asString());
  63. if(!photoNode["Mtime"].isNull())
  64. photo_.mtime = std::stol(photoNode["Mtime"].asString());
  65. if(!photoNode["TakenAt"].isNull())
  66. photo_.takenAt = std::stol(photoNode["TakenAt"].asString());
  67. if(!photoNode["ShareExpireTime"].isNull())
  68. photo_.shareExpireTime = std::stol(photoNode["ShareExpireTime"].asString());
  69. if(!value["Code"].isNull())
  70. code_ = value["Code"].asString();
  71. if(!value["Message"].isNull())
  72. message_ = value["Message"].asString();
  73. if(!value["Action"].isNull())
  74. action_ = value["Action"].asString();
  75. }
  76. std::string CreatePhotoResult::getAction()const
  77. {
  78. return action_;
  79. }
  80. std::string CreatePhotoResult::getMessage()const
  81. {
  82. return message_;
  83. }
  84. CreatePhotoResult::Photo CreatePhotoResult::getPhoto()const
  85. {
  86. return photo_;
  87. }
  88. std::string CreatePhotoResult::getCode()const
  89. {
  90. return code_;
  91. }