User.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 $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. }