Voice.php 836 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace WeWork\Message;
  3. class Voice implements ResponseMessageInterface, ReplyMessageInterface
  4. {
  5. /**
  6. * @var string
  7. */
  8. private $mediaId;
  9. /**
  10. * @param string $mediaId
  11. */
  12. public function __construct(string $mediaId)
  13. {
  14. $this->mediaId = $mediaId;
  15. }
  16. /**
  17. * @return array
  18. */
  19. public function formatForReply(): array
  20. {
  21. return [
  22. 'MsgType' => 'voice',
  23. 'Voice' => [
  24. 'MediaId' => $this->mediaId
  25. ]
  26. ];
  27. }
  28. /**
  29. * @return array
  30. */
  31. public function formatForResponse(): array
  32. {
  33. return [
  34. 'msgtype' => 'voice',
  35. 'voice' => [
  36. 'media_id' => $this->mediaId
  37. ]
  38. ];
  39. }
  40. }