TextCard.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace WeWork\Message;
  3. class TextCard implements ResponseMessageInterface
  4. {
  5. /**
  6. * @var string
  7. */
  8. private $title;
  9. /**
  10. * @var string
  11. */
  12. private $description;
  13. /**
  14. * @var string
  15. */
  16. private $url;
  17. /**
  18. * @var string
  19. */
  20. private $btnTxt;
  21. /**
  22. * @param string $title
  23. * @param string $description
  24. * @param string $url
  25. * @param string $btnTxt
  26. */
  27. public function __construct(string $title, string $description, string $url, string $btnTxt = '')
  28. {
  29. $this->title = $title;
  30. $this->description = $description;
  31. $this->url = $url;
  32. $this->btnTxt = $btnTxt;
  33. }
  34. /**
  35. * @return array
  36. */
  37. public function formatForResponse(): array
  38. {
  39. return [
  40. 'msgtype' => 'textcard',
  41. 'textcard' => [
  42. 'title' => $this->title,
  43. 'description' => $this->description,
  44. 'url' => $this->url,
  45. 'btntxt' => $this->btnTxt
  46. ]
  47. ];
  48. }
  49. }