Video.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace WeWork\Message;
  3. class Video implements ResponseMessageInterface, ReplyMessageInterface
  4. {
  5. /**
  6. * @var string
  7. */
  8. private $mediaId;
  9. /**
  10. * @var string
  11. */
  12. private $title;
  13. /**
  14. * @var string
  15. */
  16. private $description;
  17. /**
  18. * @param string $mediaId
  19. * @param string $title
  20. * @param string $description
  21. */
  22. public function __construct(string $mediaId, string $title = '', string $description = '')
  23. {
  24. $this->mediaId = $mediaId;
  25. $this->title = $title;
  26. $this->description = $description;
  27. }
  28. /**
  29. * @return array
  30. */
  31. public function formatForReply(): array
  32. {
  33. return [
  34. 'MsgType' => 'video',
  35. 'Video' => [
  36. 'MediaId' => $this->mediaId,
  37. 'Title' => $this->title,
  38. 'Description' => $this->description
  39. ]
  40. ];
  41. }
  42. /**
  43. * @return array
  44. */
  45. public function formatForResponse(): array
  46. {
  47. return [
  48. 'msgtype' => 'video',
  49. 'video' => [
  50. 'media_id' => $this->mediaId,
  51. 'title' => $this->title,
  52. 'description' => $this->description
  53. ]
  54. ];
  55. }
  56. }