IAccount.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Accounts;
  8. use Generator;
  9. use OCP\IUser;
  10. /**
  11. * Interface IAccount
  12. *
  13. * @since 15.0.0
  14. */
  15. interface IAccount extends \JsonSerializable {
  16. /**
  17. * Set a property with data
  18. *
  19. * @since 15.0.0
  20. *
  21. * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager
  22. * @param string $value
  23. * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager
  24. * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED
  25. * @param string $verificationData Optional, defaults to empty string. Since @22.0.0.
  26. * @return IAccount
  27. */
  28. public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount;
  29. /**
  30. * Get a property by its key
  31. *
  32. * @since 15.0.0
  33. *
  34. * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager
  35. * @return IAccountProperty
  36. * @throws PropertyDoesNotExistException
  37. */
  38. public function getProperty(string $property): IAccountProperty;
  39. /**
  40. * Get all properties of an account. Array indices are property names.
  41. * Values from IAccountPropertyCollections are not included in the return
  42. * array.
  43. *
  44. * @since 15.0.0
  45. * @deprecated 22.0.0 use getAllProperties()
  46. */
  47. public function getProperties(): array;
  48. /**
  49. * Set all properties of an account
  50. *
  51. * @param array<string, array<string, string>>|array<string, array<int, array<string, string>>> $properties
  52. *
  53. * e.g. `[
  54. * 'displayname' => [
  55. * 'name' => 'displayname',
  56. * 'value' => 'Jonathan Smith',
  57. * 'scope' => 'v2-federated',
  58. * 'verified' => '0',
  59. * 'verificationData' => '',
  60. * ],
  61. * 'email' => [
  62. * 'name' => 'email',
  63. * 'value' => 'jonathan@example.org',
  64. * 'scope' => 'v2-federated',
  65. * 'verified' => '0',
  66. * 'verificationData' => '',
  67. * ],
  68. * // ...
  69. * 'additional_mail' => [
  70. * [
  71. * 'name' => 'additional_mail',
  72. * 'value' => 'jon@example.org',
  73. * 'scope' => 'v2-local',
  74. * 'verified' => '0',
  75. * 'verificationData' => '',
  76. * ],
  77. * [
  78. * 'name' => 'additional_mail',
  79. * 'value' => 'jon@earth.org',
  80. * 'scope' => 'v2-local',
  81. * 'verified' => '0',
  82. * 'verificationData' => '',
  83. * ],
  84. * ],
  85. * ]`
  86. *
  87. * @since 24.0.0
  88. */
  89. public function setAllPropertiesFromJson(array $properties): IAccount;
  90. /**
  91. * Get all properties of an account. Array indices are numeric. To get
  92. * the property name, call getName() against the value.
  93. *
  94. * IAccountPropertyCollections are being flattened into an IAccountProperty
  95. * for each value.
  96. *
  97. * @since 22.0.0
  98. *
  99. * @return Generator<int, IAccountProperty>
  100. */
  101. public function getAllProperties(): Generator;
  102. /**
  103. * Set a property collection (multi-value properties)
  104. *
  105. * @since 22.0.0
  106. */
  107. public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount;
  108. /**
  109. * Returns the requested property collection (multi-value properties)
  110. *
  111. * @throws PropertyDoesNotExistException against invalid collection name
  112. * @since 22.0.0
  113. */
  114. public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection;
  115. /**
  116. * Get all properties that match the provided filters for scope and verification status
  117. *
  118. * Since 22.0.0 values from IAccountPropertyCollection are included, but also
  119. * as IAccountProperty instances. They for properties of IAccountPropertyCollection are
  120. * suffixed incrementally, i.e. #0, #1 ... #n – the numbers have no further meaning.
  121. *
  122. * @since 15.0.0
  123. *
  124. * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager
  125. * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED
  126. * @return IAccountProperty[]
  127. */
  128. public function getFilteredProperties(?string $scope = null, ?string $verified = null): array;
  129. /**
  130. * Get the related user for the account data
  131. *
  132. * @since 15.0.0
  133. *
  134. * @return IUser
  135. */
  136. public function getUser(): IUser;
  137. }