GetUserResult.cc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/ccc/model/GetUserResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::CCC;
  19. using namespace AlibabaCloud::CCC::Model;
  20. GetUserResult::GetUserResult() :
  21. ServiceResult()
  22. {}
  23. GetUserResult::GetUserResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetUserResult::~GetUserResult()
  29. {}
  30. void GetUserResult::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 userNode = value["User"];
  37. if(!userNode["UserId"].isNull())
  38. user_.userId = userNode["UserId"].asString();
  39. if(!userNode["RamId"].isNull())
  40. user_.ramId = userNode["RamId"].asString();
  41. if(!userNode["InstanceId"].isNull())
  42. user_.instanceId = userNode["InstanceId"].asString();
  43. auto allRoles = value["Roles"]["Role"];
  44. for (auto value : allRoles)
  45. {
  46. User::Role roleObject;
  47. if(!value["RoleId"].isNull())
  48. roleObject.roleId = value["RoleId"].asString();
  49. if(!value["InstanceId"].isNull())
  50. roleObject.instanceId = value["InstanceId"].asString();
  51. if(!value["RoleName"].isNull())
  52. roleObject.roleName = value["RoleName"].asString();
  53. if(!value["RoleDescription"].isNull())
  54. roleObject.roleDescription = value["RoleDescription"].asString();
  55. user_.roles.push_back(roleObject);
  56. }
  57. auto allSkillLevels = value["SkillLevels"]["SkillLevel"];
  58. for (auto value : allSkillLevels)
  59. {
  60. User::SkillLevel skillLevelObject;
  61. if(!value["SkillLevelId"].isNull())
  62. skillLevelObject.skillLevelId = value["SkillLevelId"].asString();
  63. if(!value["Level"].isNull())
  64. skillLevelObject.level = std::stoi(value["Level"].asString());
  65. auto skillNode = value["Skill"];
  66. if(!skillNode["SkillGroupId"].isNull())
  67. skillLevelObject.skill.skillGroupId = skillNode["SkillGroupId"].asString();
  68. if(!skillNode["InstanceId"].isNull())
  69. skillLevelObject.skill.instanceId = skillNode["InstanceId"].asString();
  70. if(!skillNode["SkillGroupName"].isNull())
  71. skillLevelObject.skill.skillGroupName = skillNode["SkillGroupName"].asString();
  72. if(!skillNode["SkillGroupDescription"].isNull())
  73. skillLevelObject.skill.skillGroupDescription = skillNode["SkillGroupDescription"].asString();
  74. user_.skillLevels.push_back(skillLevelObject);
  75. }
  76. auto detailNode = userNode["Detail"];
  77. if(!detailNode["LoginName"].isNull())
  78. user_.detail.loginName = detailNode["LoginName"].asString();
  79. if(!detailNode["DisplayName"].isNull())
  80. user_.detail.displayName = detailNode["DisplayName"].asString();
  81. if(!detailNode["Phone"].isNull())
  82. user_.detail.phone = detailNode["Phone"].asString();
  83. if(!detailNode["Email"].isNull())
  84. user_.detail.email = detailNode["Email"].asString();
  85. if(!detailNode["Department"].isNull())
  86. user_.detail.department = detailNode["Department"].asString();
  87. if(!value["Success"].isNull())
  88. success_ = value["Success"].asString() == "true";
  89. if(!value["Code"].isNull())
  90. code_ = value["Code"].asString();
  91. if(!value["Message"].isNull())
  92. message_ = value["Message"].asString();
  93. if(!value["HttpStatusCode"].isNull())
  94. httpStatusCode_ = std::stoi(value["HttpStatusCode"].asString());
  95. }
  96. GetUserResult::User GetUserResult::getUser()const
  97. {
  98. return user_;
  99. }
  100. std::string GetUserResult::getMessage()const
  101. {
  102. return message_;
  103. }
  104. int GetUserResult::getHttpStatusCode()const
  105. {
  106. return httpStatusCode_;
  107. }
  108. std::string GetUserResult::getCode()const
  109. {
  110. return code_;
  111. }
  112. bool GetUserResult::getSuccess()const
  113. {
  114. return success_;
  115. }