1
0

INotification.php 7.2 KB

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