INotification.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. * @package OCP\Notification
  29. * @since 9.0.0
  30. */
  31. interface INotification {
  32. /**
  33. * @param string $app
  34. * @return $this
  35. * @throws \InvalidArgumentException if the app id is invalid
  36. * @since 9.0.0
  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 \InvalidArgumentException if the user id is invalid
  48. * @since 9.0.0
  49. */
  50. public function setUser(string $user): INotification;
  51. /**
  52. * @return string
  53. * @since 9.0.0
  54. */
  55. public function getUser(): string;
  56. /**
  57. * @param \DateTime $dateTime
  58. * @return $this
  59. * @throws \InvalidArgumentException if the $dateTime is invalid
  60. * @since 9.0.0
  61. */
  62. public function setDateTime(\DateTime $dateTime): INotification;
  63. /**
  64. * @return \DateTime
  65. * @since 9.0.0
  66. */
  67. public function getDateTime(): \DateTime;
  68. /**
  69. * @param string $type
  70. * @param string $id
  71. * @return $this
  72. * @throws \InvalidArgumentException if the object type or id is invalid
  73. * @since 9.0.0
  74. */
  75. public function setObject(string $type, string $id): INotification;
  76. /**
  77. * @return string
  78. * @since 9.0.0
  79. */
  80. public function getObjectType(): string;
  81. /**
  82. * @return string
  83. * @since 9.0.0
  84. */
  85. public function getObjectId(): string;
  86. /**
  87. * @param string $subject
  88. * @param array $parameters
  89. * @return $this
  90. * @throws \InvalidArgumentException if the subject or parameters are invalid
  91. * @since 9.0.0
  92. */
  93. public function setSubject(string $subject, array $parameters = []): INotification;
  94. /**
  95. * @return string
  96. * @since 9.0.0
  97. */
  98. public function getSubject(): string;
  99. /**
  100. * @return array
  101. * @since 9.0.0
  102. */
  103. public function getSubjectParameters(): array;
  104. /**
  105. * Set a parsed subject
  106. *
  107. * HTML is not allowed in the parsed subject and will be escaped
  108. * automatically by the clients. You can use the RichObjectString system
  109. * provided by the Nextcloud server to highlight important parameters via
  110. * the setRichSubject method, but make sure, that a plain text message is
  111. * always set via setParsedSubject, to support clients which can not handle
  112. * rich strings.
  113. *
  114. * See https://github.com/nextcloud/server/issues/1706 for more information.
  115. *
  116. * @param string $subject
  117. * @return $this
  118. * @throws \InvalidArgumentException if the subject is invalid
  119. * @since 9.0.0
  120. */
  121. public function setParsedSubject(string $subject): INotification;
  122. /**
  123. * @return string
  124. * @since 9.0.0
  125. */
  126. public function getParsedSubject(): string;
  127. /**
  128. * Set a RichObjectString subject
  129. *
  130. * HTML is not allowed in the rich subject and will be escaped automatically
  131. * by the clients, but you can use the RichObjectString system provided by
  132. * the Nextcloud server to highlight important parameters.
  133. * Also make sure, that a plain text subject is always set via
  134. * setParsedSubject, to support clients which can not handle rich strings.
  135. *
  136. * See https://github.com/nextcloud/server/issues/1706 for more information.
  137. *
  138. * @param string $subject
  139. * @param array $parameters
  140. * @return $this
  141. * @throws \InvalidArgumentException if the subject or parameters are invalid
  142. * @since 11.0.0
  143. */
  144. public function setRichSubject(string $subject, array $parameters = []): INotification;
  145. /**
  146. * @return string
  147. * @since 11.0.0
  148. */
  149. public function getRichSubject(): string;
  150. /**
  151. * @return array[]
  152. * @since 11.0.0
  153. */
  154. public function getRichSubjectParameters(): array;
  155. /**
  156. * @param string $message
  157. * @param array $parameters
  158. * @return $this
  159. * @throws \InvalidArgumentException if the message or parameters are invalid
  160. * @since 9.0.0
  161. */
  162. public function setMessage(string $message, array $parameters = []): INotification;
  163. /**
  164. * @return string
  165. * @since 9.0.0
  166. */
  167. public function getMessage(): string;
  168. /**
  169. * @return array
  170. * @since 9.0.0
  171. */
  172. public function getMessageParameters(): array;
  173. /**
  174. * Set a parsed message
  175. *
  176. * HTML is not allowed in the parsed message and will be escaped
  177. * automatically by the clients. You can use the RichObjectString system
  178. * provided by the Nextcloud server to highlight important parameters via
  179. * the setRichMessage method, but make sure, that a plain text message is
  180. * always set via setParsedMessage, to support clients which can not handle
  181. * rich strings.
  182. *
  183. * See https://github.com/nextcloud/server/issues/1706 for more information.
  184. *
  185. * @param string $message
  186. * @return $this
  187. * @throws \InvalidArgumentException if the message is invalid
  188. * @since 9.0.0
  189. */
  190. public function setParsedMessage(string $message): INotification;
  191. /**
  192. * @return string
  193. * @since 9.0.0
  194. */
  195. public function getParsedMessage(): string;
  196. /**
  197. * Set a RichObjectString message
  198. *
  199. * HTML is not allowed in the rich message and will be escaped automatically
  200. * by the clients, but you can use the RichObjectString system provided by
  201. * the Nextcloud server to highlight important parameters.
  202. * Also make sure, that a plain text message is always set via
  203. * setParsedMessage, to support clients which can not handle rich strings.
  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 \InvalidArgumentException if the message or parameters are invalid
  211. * @since 11.0.0
  212. */
  213. public function setRichMessage(string $message, array $parameters = []): INotification;
  214. /**
  215. * @return string
  216. * @since 11.0.0
  217. */
  218. public function getRichMessage(): string;
  219. /**
  220. * @return array[]
  221. * @since 11.0.0
  222. */
  223. public function getRichMessageParameters(): array;
  224. /**
  225. * @param string $link
  226. * @return $this
  227. * @throws \InvalidArgumentException if the link is invalid
  228. * @since 9.0.0
  229. */
  230. public function setLink(string $link): INotification;
  231. /**
  232. * @return string
  233. * @since 9.0.0
  234. */
  235. public function getLink(): string;
  236. /**
  237. * @param string $icon
  238. * @return $this
  239. * @throws \InvalidArgumentException if the icon is invalid
  240. * @since 11.0.0
  241. */
  242. public function setIcon(string $icon): INotification;
  243. /**
  244. * @return string
  245. * @since 11.0.0
  246. */
  247. public function getIcon(): string;
  248. /**
  249. * @return IAction
  250. * @since 9.0.0
  251. */
  252. public function createAction(): IAction;
  253. /**
  254. * @param IAction $action
  255. * @return $this
  256. * @throws \InvalidArgumentException if the action is invalid
  257. * @since 9.0.0
  258. */
  259. public function addAction(IAction $action): INotification;
  260. /**
  261. * @return IAction[]
  262. * @since 9.0.0
  263. */
  264. public function getActions(): array;
  265. /**
  266. * @param IAction $action
  267. * @return $this
  268. * @throws \InvalidArgumentException if the action is invalid
  269. * @since 9.0.0
  270. */
  271. public function addParsedAction(IAction $action): INotification;
  272. /**
  273. * @return IAction[]
  274. * @since 9.0.0
  275. */
  276. public function getParsedActions(): array;
  277. /**
  278. * @return bool
  279. * @since 9.0.0
  280. */
  281. public function isValid(): bool;
  282. /**
  283. * @return bool
  284. * @since 9.0.0
  285. */
  286. public function isValidParsed(): bool;
  287. }