ListUsersResult.cc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/aliyuncvc/model/ListUsersResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Aliyuncvc;
  19. using namespace AlibabaCloud::Aliyuncvc::Model;
  20. ListUsersResult::ListUsersResult() :
  21. ServiceResult()
  22. {}
  23. ListUsersResult::ListUsersResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ListUsersResult::~ListUsersResult()
  29. {}
  30. void ListUsersResult::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["TotalCount"].isNull())
  38. data_.totalCount = std::stoi(dataNode["TotalCount"].asString());
  39. if(!dataNode["PageSize"].isNull())
  40. data_.pageSize = std::stoi(dataNode["PageSize"].asString());
  41. if(!dataNode["PageNumber"].isNull())
  42. data_.pageNumber = std::stoi(dataNode["PageNumber"].asString());
  43. auto allUserInfosNode = dataNode["UserInfos"]["UserInfo"];
  44. for (auto dataNodeUserInfosUserInfo : allUserInfosNode)
  45. {
  46. Data::UserInfo userInfoObject;
  47. if(!dataNodeUserInfosUserInfo["CreateTime"].isNull())
  48. userInfoObject.createTime = std::stol(dataNodeUserInfosUserInfo["CreateTime"].asString());
  49. if(!dataNodeUserInfosUserInfo["GroupName"].isNull())
  50. userInfoObject.groupName = dataNodeUserInfosUserInfo["GroupName"].asString();
  51. if(!dataNodeUserInfosUserInfo["UserName"].isNull())
  52. userInfoObject.userName = dataNodeUserInfosUserInfo["UserName"].asString();
  53. if(!dataNodeUserInfosUserInfo["GroupId"].isNull())
  54. userInfoObject.groupId = dataNodeUserInfosUserInfo["GroupId"].asString();
  55. if(!dataNodeUserInfosUserInfo["DepartName"].isNull())
  56. userInfoObject.departName = dataNodeUserInfosUserInfo["DepartName"].asString();
  57. if(!dataNodeUserInfosUserInfo["DepartId"].isNull())
  58. userInfoObject.departId = dataNodeUserInfosUserInfo["DepartId"].asString();
  59. if(!dataNodeUserInfosUserInfo["UserEmail"].isNull())
  60. userInfoObject.userEmail = dataNodeUserInfosUserInfo["UserEmail"].asString();
  61. if(!dataNodeUserInfosUserInfo["UserTel"].isNull())
  62. userInfoObject.userTel = dataNodeUserInfosUserInfo["UserTel"].asString();
  63. if(!dataNodeUserInfosUserInfo["UserMobile"].isNull())
  64. userInfoObject.userMobile = dataNodeUserInfosUserInfo["UserMobile"].asString();
  65. if(!dataNodeUserInfosUserInfo["UserAvatarUrl"].isNull())
  66. userInfoObject.userAvatarUrl = dataNodeUserInfosUserInfo["UserAvatarUrl"].asString();
  67. if(!dataNodeUserInfosUserInfo["JobName"].isNull())
  68. userInfoObject.jobName = dataNodeUserInfosUserInfo["JobName"].asString();
  69. data_.userInfos.push_back(userInfoObject);
  70. }
  71. if(!value["ErrorCode"].isNull())
  72. errorCode_ = std::stoi(value["ErrorCode"].asString());
  73. if(!value["Message"].isNull())
  74. message_ = value["Message"].asString();
  75. if(!value["Success"].isNull())
  76. success_ = value["Success"].asString() == "true";
  77. }
  78. std::string ListUsersResult::getMessage()const
  79. {
  80. return message_;
  81. }
  82. ListUsersResult::Data ListUsersResult::getData()const
  83. {
  84. return data_;
  85. }
  86. int ListUsersResult::getErrorCode()const
  87. {
  88. return errorCode_;
  89. }
  90. bool ListUsersResult::getSuccess()const
  91. {
  92. return success_;
  93. }