INotification.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OCP\Notification;
  9. /**
  10. * Interface INotification
  11. *
  12. * @since 9.0.0
  13. */
  14. interface INotification {
  15. /**
  16. * @param string $app
  17. * @return $this
  18. * @throws InvalidValueException if the app id is invalid
  19. * @since 9.0.0
  20. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  21. */
  22. public function setApp(string $app): INotification;
  23. /**
  24. * @return string
  25. * @since 9.0.0
  26. */
  27. public function getApp(): string;
  28. /**
  29. * @param string $user
  30. * @return $this
  31. * @throws InvalidValueException if the user id is invalid
  32. * @since 9.0.0
  33. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  34. */
  35. public function setUser(string $user): INotification;
  36. /**
  37. * @return string
  38. * @since 9.0.0
  39. */
  40. public function getUser(): string;
  41. /**
  42. * @param \DateTime $dateTime
  43. * @return $this
  44. * @throws InvalidValueException if the $dateTime is invalid
  45. * @since 9.0.0
  46. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  47. */
  48. public function setDateTime(\DateTime $dateTime): INotification;
  49. /**
  50. * @return \DateTime
  51. * @since 9.0.0
  52. */
  53. public function getDateTime(): \DateTime;
  54. /**
  55. * @param string $type
  56. * @param string $id
  57. * @return $this
  58. * @throws InvalidValueException if the object type or id is invalid
  59. * @since 9.0.0
  60. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  61. */
  62. public function setObject(string $type, string $id): INotification;
  63. /**
  64. * @return string
  65. * @since 9.0.0
  66. */
  67. public function getObjectType(): string;
  68. /**
  69. * @return string
  70. * @since 9.0.0
  71. */
  72. public function getObjectId(): string;
  73. /**
  74. * @param string $subject
  75. * @param array $parameters
  76. * @return $this
  77. * @throws InvalidValueException if the subject or parameters are invalid
  78. * @since 9.0.0
  79. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  80. */
  81. public function setSubject(string $subject, array $parameters = []): INotification;
  82. /**
  83. * @return string
  84. * @since 9.0.0
  85. */
  86. public function getSubject(): string;
  87. /**
  88. * @return array
  89. * @since 9.0.0
  90. */
  91. public function getSubjectParameters(): array;
  92. /**
  93. * Set a parsed subject
  94. *
  95. * HTML is not allowed in the parsed subject and will be escaped
  96. * automatically by the clients. You can use the RichObjectString system
  97. * provided by the Nextcloud server to highlight important parameters via
  98. * the setRichSubject method.
  99. *
  100. * See https://github.com/nextcloud/server/issues/1706 for more information.
  101. *
  102. * @param string $subject
  103. * @return $this
  104. * @throws InvalidValueException if the subject is invalid
  105. * @since 9.0.0
  106. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  107. */
  108. public function setParsedSubject(string $subject): INotification;
  109. /**
  110. * @return string
  111. * @since 9.0.0
  112. */
  113. public function getParsedSubject(): string;
  114. /**
  115. * Set a RichObjectString subject
  116. *
  117. * HTML is not allowed in the rich subject and will be escaped automatically
  118. * by the clients, but you can use the RichObjectString system provided by
  119. * the Nextcloud server to highlight important parameters.
  120. *
  121. * See https://github.com/nextcloud/server/issues/1706 for more information.
  122. *
  123. * @param string $subject
  124. * @param array $parameters
  125. * @return $this
  126. * @throws InvalidValueException if the subject or parameters are invalid
  127. * @since 11.0.0
  128. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  129. */
  130. public function setRichSubject(string $subject, array $parameters = []): INotification;
  131. /**
  132. * @return string
  133. * @since 11.0.0
  134. */
  135. public function getRichSubject(): string;
  136. /**
  137. * @return array[]
  138. * @since 11.0.0
  139. */
  140. public function getRichSubjectParameters(): array;
  141. /**
  142. * @param string $message
  143. * @param array $parameters
  144. * @return $this
  145. * @throws InvalidValueException if the message or parameters are invalid
  146. * @since 9.0.0
  147. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  148. */
  149. public function setMessage(string $message, array $parameters = []): INotification;
  150. /**
  151. * @return string
  152. * @since 9.0.0
  153. */
  154. public function getMessage(): string;
  155. /**
  156. * @return array
  157. * @since 9.0.0
  158. */
  159. public function getMessageParameters(): array;
  160. /**
  161. * Set a parsed message
  162. *
  163. * HTML is not allowed in the parsed message and will be escaped
  164. * automatically by the clients. You can use the RichObjectString system
  165. * provided by the Nextcloud server to highlight important parameters via
  166. * the setRichMessage method.
  167. *
  168. * See https://github.com/nextcloud/server/issues/1706 for more information.
  169. *
  170. * @param string $message
  171. * @return $this
  172. * @throws InvalidValueException if the message is invalid
  173. * @since 9.0.0
  174. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  175. */
  176. public function setParsedMessage(string $message): INotification;
  177. /**
  178. * @return string
  179. * @since 9.0.0
  180. */
  181. public function getParsedMessage(): string;
  182. /**
  183. * Set a RichObjectString message
  184. *
  185. * HTML is not allowed in the rich message and will be escaped automatically
  186. * by the clients, but you can use the RichObjectString system provided by
  187. * the Nextcloud server to highlight important parameters.
  188. *
  189. * See https://github.com/nextcloud/server/issues/1706 for more information.
  190. *
  191. * @param string $message
  192. * @param array $parameters
  193. * @return $this
  194. * @throws InvalidValueException if the message or parameters are invalid
  195. * @since 11.0.0
  196. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  197. */
  198. public function setRichMessage(string $message, array $parameters = []): INotification;
  199. /**
  200. * @return string
  201. * @since 11.0.0
  202. */
  203. public function getRichMessage(): string;
  204. /**
  205. * @return array[]
  206. * @since 11.0.0
  207. */
  208. public function getRichMessageParameters(): array;
  209. /**
  210. * @param string $link
  211. * @return $this
  212. * @throws InvalidValueException if the link is invalid
  213. * @since 9.0.0
  214. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  215. */
  216. public function setLink(string $link): INotification;
  217. /**
  218. * @return string
  219. * @since 9.0.0
  220. */
  221. public function getLink(): string;
  222. /**
  223. * @param string $icon
  224. * @return $this
  225. * @throws InvalidValueException if the icon is invalid
  226. * @since 11.0.0
  227. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  228. */
  229. public function setIcon(string $icon): INotification;
  230. /**
  231. * @return string
  232. * @since 11.0.0
  233. */
  234. public function getIcon(): string;
  235. /**
  236. * @return IAction
  237. * @since 9.0.0
  238. */
  239. public function createAction(): IAction;
  240. /**
  241. * @param IAction $action
  242. * @return $this
  243. * @throws InvalidValueException if the action is invalid
  244. * @since 9.0.0
  245. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  246. */
  247. public function addAction(IAction $action): INotification;
  248. /**
  249. * @return IAction[]
  250. * @since 9.0.0
  251. */
  252. public function getActions(): array;
  253. /**
  254. * @param IAction $action
  255. * @return $this
  256. * @throws InvalidValueException if the action is invalid
  257. * @since 9.0.0
  258. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  259. */
  260. public function addParsedAction(IAction $action): INotification;
  261. /**
  262. * @return IAction[]
  263. * @since 9.0.0
  264. */
  265. public function getParsedActions(): array;
  266. /**
  267. * @return bool
  268. * @since 9.0.0
  269. */
  270. public function isValid(): bool;
  271. /**
  272. * @return bool
  273. * @since 9.0.0
  274. */
  275. public function isValidParsed(): bool;
  276. }