1
0

IAccount.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Julius Härtl <jus@bitgrid.net>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP\Accounts;
  26. use Generator;
  27. use OCP\IUser;
  28. /**
  29. * Interface IAccount
  30. *
  31. * @since 15.0.0
  32. */
  33. interface IAccount extends \JsonSerializable {
  34. /**
  35. * Set a property with data
  36. *
  37. * @since 15.0.0
  38. *
  39. * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager
  40. * @param string $value
  41. * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager
  42. * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED
  43. * @param string $verificationData Optional, defaults to empty string. Since @22.0.0.
  44. * @return IAccount
  45. */
  46. public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount;
  47. /**
  48. * Get a property by its key
  49. *
  50. * @since 15.0.0
  51. *
  52. * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager
  53. * @return IAccountProperty
  54. * @throws PropertyDoesNotExistException
  55. */
  56. public function getProperty(string $property): IAccountProperty;
  57. /**
  58. * Get all properties of an account. Array indices are property names.
  59. * Values from IAccountPropertyCollections are not included in the return
  60. * array.
  61. *
  62. * @since 15.0.0
  63. * @deprecated 22.0.0 use getAllProperties()
  64. */
  65. public function getProperties(): array;
  66. /**
  67. * Set all properties of an account
  68. *
  69. * @param array<string, array<string, string>>|array<string, array<int, array<string, string>>> $properties
  70. *
  71. * e.g. `[
  72. * 'displayname' => [
  73. * 'name' => 'displayname',
  74. * 'value' => 'Jonathan Smith',
  75. * 'scope' => 'v2-federated',
  76. * 'verified' => '0',
  77. * 'verificationData' => '',
  78. * ],
  79. * 'email' => [
  80. * 'name' => 'email',
  81. * 'value' => 'jonathan@example.org',
  82. * 'scope' => 'v2-federated',
  83. * 'verified' => '0',
  84. * 'verificationData' => '',
  85. * ],
  86. * // ...
  87. * 'additional_mail' => [
  88. * [
  89. * 'name' => 'additional_mail',
  90. * 'value' => 'jon@example.org',
  91. * 'scope' => 'v2-local',
  92. * 'verified' => '0',
  93. * 'verificationData' => '',
  94. * ],
  95. * [
  96. * 'name' => 'additional_mail',
  97. * 'value' => 'jon@earth.org',
  98. * 'scope' => 'v2-local',
  99. * 'verified' => '0',
  100. * 'verificationData' => '',
  101. * ],
  102. * ],
  103. * ]`
  104. *
  105. * @since 24.0.0
  106. */
  107. public function setAllPropertiesFromJson(array $properties): IAccount;
  108. /**
  109. * Get all properties of an account. Array indices are numeric. To get
  110. * the property name, call getName() against the value.
  111. *
  112. * IAccountPropertyCollections are being flattened into an IAccountProperty
  113. * for each value.
  114. *
  115. * @since 22.0.0
  116. *
  117. * @return Generator<int, IAccountProperty>
  118. */
  119. public function getAllProperties(): Generator;
  120. /**
  121. * Set a property collection (multi-value properties)
  122. *
  123. * @since 22.0.0
  124. */
  125. public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount;
  126. /**
  127. * Returns the requestes propery collection (multi-value properties)
  128. *
  129. * @throws PropertyDoesNotExistException against invalid collection name
  130. * @since 22.0.0
  131. */
  132. public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection;
  133. /**
  134. * Get all properties that match the provided filters for scope and verification status
  135. *
  136. * Since 22.0.0 values from IAccountPropertyCollection are included, but also
  137. * as IAccountProperty instances. They for properties of IAccountPropertyCollection are
  138. * suffixed incrementally, i.e. #0, #1 ... #n – the numbers have no further meaning.
  139. *
  140. * @since 15.0.0
  141. *
  142. * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager
  143. * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED
  144. * @return IAccountProperty[]
  145. */
  146. public function getFilteredProperties(string $scope = null, string $verified = null): array;
  147. /**
  148. * Get the related user for the account data
  149. *
  150. * @since 15.0.0
  151. *
  152. * @return IUser
  153. */
  154. public function getUser(): IUser;
  155. }