IManager.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Mail\Provider;
  8. /**
  9. * Mail Provider Manager Interface
  10. *
  11. * This interface is a base requirement of methods and functionality used to construct a mail provider manager object
  12. *
  13. * @since 30.0.0
  14. *
  15. */
  16. interface IManager {
  17. /**
  18. * determine if any mail providers are registered
  19. *
  20. * @since 30.0.0
  21. *
  22. * @return bool
  23. */
  24. public function has(): bool;
  25. /**
  26. * retrieve a count of how many mail providers are registered
  27. *
  28. * @since 30.0.0
  29. *
  30. * @return int
  31. */
  32. public function count(): int;
  33. /**
  34. * retrieve which mail providers are registered
  35. *
  36. * @since 30.0.0
  37. *
  38. * @return array<string,String> collection of provider id and label ['jmap' => 'JMap Connector']
  39. */
  40. public function types(): array;
  41. /**
  42. * retrieve all registered mail providers
  43. *
  44. * @since 30.0.0
  45. *
  46. * @return array<string,IProvider> collection of provider id and object ['jmap' => IProviderObject]
  47. */
  48. public function providers(): array;
  49. /**
  50. * retrieve a provider with a specific id
  51. *
  52. * @since 30.0.0
  53. *
  54. * @param string $providerId provider id
  55. *
  56. * @return IProvider|null
  57. */
  58. public function findProviderById(string $providerId): IProvider|null;
  59. /**
  60. * retrieve all services for all registered mail providers
  61. *
  62. * @since 30.0.0
  63. *
  64. * @param string $userId user id
  65. *
  66. * @return array<string,array<string,IService>> collection of provider id, service id and object ['jmap' => ['Service1' => IServiceObject]]
  67. */
  68. public function services(string $userId): array;
  69. /**
  70. * retrieve a service with a specific id
  71. *
  72. * @since 30.0.0
  73. *
  74. * @param string $userId user id
  75. * @param string $serviceId service id
  76. * @param string $providerId provider id
  77. *
  78. * @return IService|null returns service object or null if none found
  79. */
  80. public function findServiceById(string $userId, string $serviceId, ?string $providerId = null): IService|null;
  81. /**
  82. * retrieve a service for a specific mail address
  83. * returns first service with specific primary address
  84. *
  85. * @since 30.0.0
  86. *
  87. * @param string $userId user id
  88. * @param string $address mail address (e.g. test@example.com)
  89. * @param string $providerId provider id
  90. *
  91. * @return IService|null returns service object or null if none found
  92. */
  93. public function findServiceByAddress(string $userId, string $address, ?string $providerId = null): IService|null;
  94. }