INotification.php 8.4 KB

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