暫無描述

MailAttributes.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace AliyunMNS\Model;
  3. use AliyunMNS\Constants;
  4. /**
  5. * Please refer to
  6. * https://docs.aliyun.com/?spm=#/pub/mns/api_reference/intro&intro
  7. * for more details
  8. */
  9. class MailAttributes
  10. {
  11. public $subject;
  12. public $accountName;
  13. public $addressType;
  14. public $replyToAddress;
  15. public $isHtml;
  16. public function __construct(
  17. $subject, $accountName, $addressType=0, $replyToAddress=false, $isHtml = false)
  18. {
  19. $this->subject = $subject;
  20. $this->accountName = $accountName;
  21. $this->addressType = $addressType;
  22. $this->replyToAddress = $replyToAddress;
  23. $this->isHtml = $isHtml;
  24. }
  25. public function setSubject($subject)
  26. {
  27. $this->subject = $subject;
  28. }
  29. public function getSubject()
  30. {
  31. return $this->subject;
  32. }
  33. public function setAccountName($accountName)
  34. {
  35. $this->accountName = $accountName;
  36. }
  37. public function getAccountName()
  38. {
  39. return $this->accountName;
  40. }
  41. public function setAddressType($addressType)
  42. {
  43. $this->addressType = $addressType;
  44. }
  45. public function getAddressType()
  46. {
  47. return $this->addressType;
  48. }
  49. public function setReplyToAddress($replyToAddress)
  50. {
  51. $this->replyToAddress = $replyToAddress;
  52. }
  53. public function getReplyToAddress()
  54. {
  55. return $this->replyToAddress;
  56. }
  57. public function setIsHtml($isHtml)
  58. {
  59. $this->isHtml = $isHtml;
  60. }
  61. public function getIsHtml()
  62. {
  63. return $this->isHtml;
  64. }
  65. public function writeXML(\XMLWriter $xmlWriter)
  66. {
  67. $jsonArray = array();
  68. if ($this->subject !== NULL)
  69. {
  70. $jsonArray[Constants::SUBJECT] = $this->subject;
  71. }
  72. if ($this->accountName !== NULL)
  73. {
  74. $jsonArray[Constants::ACCOUNT_NAME] = $this->accountName;
  75. }
  76. if ($this->addressType !== NULL)
  77. {
  78. $jsonArray[Constants::ADDRESS_TYPE] = $this->addressType;
  79. }
  80. else
  81. {
  82. $jsonArray[Constants::ADDRESS_TYPE] = 0;
  83. }
  84. if ($this->replyToAddress !== NULL)
  85. {
  86. if ($this->replyToAddress === TRUE)
  87. {
  88. $jsonArray[Constants::REPLY_TO_ADDRESS] = "1";
  89. }
  90. else
  91. {
  92. $jsonArray[Constants::REPLY_TO_ADDRESS] = "0";
  93. }
  94. }
  95. if ($this->isHtml !== NULL)
  96. {
  97. if ($this->isHtml === TRUE)
  98. {
  99. $jsonArray[Constants::IS_HTML] = "1";
  100. }
  101. else
  102. {
  103. $jsonArray[Constants::IS_HTML] = "0";
  104. }
  105. }
  106. if (!empty($jsonArray))
  107. {
  108. $xmlWriter->writeElement(Constants::DIRECT_MAIL, json_encode($jsonArray));
  109. }
  110. }
  111. }
  112. ?>