|
| 1 | +<?php |
| 2 | +namespace Fortifi\Api\V1\Requests; |
| 3 | + |
| 4 | +use Fortifi\Api\Core\ApiRequest; |
| 5 | +use Packaged\Helpers\Objects; |
| 6 | +use Packaged\Helpers\Strings; |
| 7 | + |
| 8 | +class NotificationRequest |
| 9 | + extends ApiRequest |
| 10 | + implements \JsonSerializable |
| 11 | +{ |
| 12 | + |
| 13 | + #[\ReturnTypeWillChange] |
| 14 | + public function jsonSerialize() |
| 15 | + { |
| 16 | + return [ |
| 17 | + "campaignFid" => $this->getCampaignFid(), |
| 18 | + "companyFid" => $this->getCompanyFid(), |
| 19 | + "messageFid" => $this->getMessageFid(), |
| 20 | + "bounced" => $this->isBounced(), |
| 21 | + "opened" => $this->isOpened(), |
| 22 | + "clicked" => $this->isClicked(), |
| 23 | + "complained" => $this->isComplained(), |
| 24 | + "subject" => $this->getSubject(), |
| 25 | + "sentTimestamp" => $this->getSentTimestamp(), |
| 26 | + "recipientEmails" => $this->getRecipientEmails(), |
| 27 | + ]; |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @param mixed $default |
| 32 | + * @param bool $trim Trim Value |
| 33 | + * |
| 34 | + * @return string |
| 35 | + */ |
| 36 | + public function getCampaignFid($default = null, $trim = true) |
| 37 | + { |
| 38 | + $value = Objects::property($this->_getResultJson(), 'campaignFid', $default); |
| 39 | + return $trim ? Strings::ntrim($value) : $value; |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * @param mixed $default |
| 44 | + * @param bool $trim Trim Value |
| 45 | + * |
| 46 | + * @return string |
| 47 | + */ |
| 48 | + public function getCompanyFid($default = null, $trim = true) |
| 49 | + { |
| 50 | + $value = Objects::property($this->_getResultJson(), 'companyFid', $default); |
| 51 | + return $trim ? Strings::ntrim($value) : $value; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @param mixed $default |
| 56 | + * @param bool $trim Trim Value |
| 57 | + * |
| 58 | + * @return string |
| 59 | + */ |
| 60 | + public function getMessageFid($default = null, $trim = true) |
| 61 | + { |
| 62 | + $value = Objects::property($this->_getResultJson(), 'messageFid', $default); |
| 63 | + return $trim ? Strings::ntrim($value) : $value; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @param bool $default |
| 68 | + * |
| 69 | + * @return boolean |
| 70 | + */ |
| 71 | + public function isBounced($default = false) |
| 72 | + { |
| 73 | + return Objects::property($this->_getResultJson(), 'bounced', $default); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * @param bool $default |
| 78 | + * |
| 79 | + * @return boolean |
| 80 | + */ |
| 81 | + public function isOpened($default = false) |
| 82 | + { |
| 83 | + return Objects::property($this->_getResultJson(), 'opened', $default); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @param bool $default |
| 88 | + * |
| 89 | + * @return boolean |
| 90 | + */ |
| 91 | + public function isClicked($default = false) |
| 92 | + { |
| 93 | + return Objects::property($this->_getResultJson(), 'clicked', $default); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * @param bool $default |
| 98 | + * |
| 99 | + * @return boolean |
| 100 | + */ |
| 101 | + public function isComplained($default = false) |
| 102 | + { |
| 103 | + return Objects::property($this->_getResultJson(), 'complained', $default); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * @param mixed $default |
| 108 | + * @param bool $trim Trim Value |
| 109 | + * |
| 110 | + * @return string |
| 111 | + */ |
| 112 | + public function getSubject($default = null, $trim = true) |
| 113 | + { |
| 114 | + $value = Objects::property($this->_getResultJson(), 'subject', $default); |
| 115 | + return $trim ? Strings::ntrim($value) : $value; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * @param mixed $default |
| 120 | + * @param bool $trim Trim Value |
| 121 | + * |
| 122 | + * @return string |
| 123 | + */ |
| 124 | + public function getSentTimestamp($default = null, $trim = true) |
| 125 | + { |
| 126 | + $value = Objects::property($this->_getResultJson(), 'sentTimestamp', $default); |
| 127 | + return $trim ? Strings::ntrim($value) : $value; |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * @param mixed $default |
| 132 | + * |
| 133 | + * @return string[] |
| 134 | + */ |
| 135 | + public function getRecipientEmails($default = []) |
| 136 | + { |
| 137 | + return Objects::property($this->_getResultJson(), 'recipientEmails', $default); |
| 138 | + } |
| 139 | + |
| 140 | + protected function _prepareResult($result) |
| 141 | + { |
| 142 | + $return = parent::_prepareResult($result); |
| 143 | + |
| 144 | + |
| 145 | + return $return; |
| 146 | + } |
| 147 | +} |
0 commit comments