PushMessage.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace App\Libs\Push\HuaWei\Admin\Msg;
  3. class PushMessage
  4. {
  5. private $data;
  6. private $notification;
  7. private $android;
  8. private $apns;
  9. private $webpush;
  10. private $token;
  11. private $topic;
  12. private $condition;
  13. private $fields;
  14. public function __construct()
  15. {
  16. $this->fields = array();
  17. $this->token = null;
  18. $this->condition = null;
  19. $this->topic = null;
  20. $this->notification = null;
  21. }
  22. public function data($value)
  23. {
  24. $this->data = $value;
  25. }
  26. public function notification($value)
  27. {
  28. $this->notification = $value;
  29. }
  30. public function android($value)
  31. {
  32. $this->android = $value;
  33. }
  34. public function token($value)
  35. {
  36. $this->token = $value;
  37. }
  38. public function get_token()
  39. {
  40. return $this->token;
  41. }
  42. public function topic($value)
  43. {
  44. $this->topic = $value;
  45. }
  46. public function condition($value)
  47. {
  48. $this->condition = $value;
  49. }
  50. public function apns($value)
  51. {
  52. $this->apns = $value;
  53. }
  54. public function webpush($value)
  55. {
  56. $this->webpush = $value;
  57. }
  58. public function getFields()
  59. {
  60. return $this->fields;
  61. }
  62. public function buildFields()
  63. {
  64. $keys = array(
  65. 'data',
  66. 'notification',
  67. 'android',
  68. 'token',
  69. 'topic',
  70. 'condition',
  71. 'apns',
  72. 'webpush'
  73. );
  74. foreach ($keys as $key) {
  75. if (isset($this->$key)) {
  76. $this->fields[$key] = $this->$key;
  77. }
  78. }
  79. }
  80. }