You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.5 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Remote;
  25. use OCP\Remote\IUser;
  26. class User implements IUser {
  27. public const EXPECTED_KEYS = [
  28. 'id',
  29. 'email',
  30. 'displayname',
  31. 'phone',
  32. 'address',
  33. 'website',
  34. 'groups',
  35. 'language',
  36. 'quota'
  37. ];
  38. /** @var array */
  39. private $data;
  40. public function __construct(array $data) {
  41. $this->data = $data;
  42. }
  43. /**
  44. * @return string
  45. */
  46. public function getUserId() {
  47. return $this->data['id'];
  48. }
  49. /**
  50. * @return string
  51. */
  52. public function getEmail() {
  53. return $this->data['email'];
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getDisplayName() {
  59. return $this->data['displayname'];
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getPhone() {
  65. return $this->data['phone'];
  66. }
  67. /**
  68. * @return string
  69. */
  70. public function getAddress() {
  71. return $this->data['address'];
  72. }
  73. /**
  74. * @return string
  75. */
  76. public function getWebsite() {
  77. return $this->data['website'];
  78. }
  79. /**
  80. * @return string
  81. */
  82. public function getTwitter() {
  83. return isset($this->data['twitter']) ? $this->data['twitter'] : '';
  84. }
  85. /**
  86. * @return string[]
  87. */
  88. public function getGroups() {
  89. return $this->data['groups'];
  90. }
  91. /**
  92. * @return string
  93. */
  94. public function getLanguage() {
  95. return $this->data['language'];
  96. }
  97. /**
  98. * @return int
  99. */
  100. public function getUsedSpace() {
  101. return $this->data['quota']['used'];
  102. }
  103. /**
  104. * @return int
  105. */
  106. public function getFreeSpace() {
  107. return $this->data['quota']['free'];
  108. }
  109. /**
  110. * @return int
  111. */
  112. public function getTotalSpace() {
  113. return $this->data['quota']['total'];
  114. }
  115. /**
  116. * @return int
  117. */
  118. public function getQuota() {
  119. return $this->data['quota']['quota'];
  120. }
  121. }