CaseEntity.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Model;
  7. use Magento\Framework\Data\Collection\AbstractDb;
  8. use Magento\Framework\Model\AbstractModel;
  9. use Magento\Framework\Model\Context;
  10. use Magento\Framework\Model\ResourceModel\AbstractResource;
  11. use Magento\Framework\Registry;
  12. use Magento\Framework\Serialize\SerializerInterface;
  13. use Magento\Signifyd\Api\Data\CaseInterface;
  14. /**
  15. * Implementation of Signifyd Case interface.
  16. */
  17. class CaseEntity extends AbstractModel implements CaseInterface
  18. {
  19. /**
  20. * @var string
  21. */
  22. protected $_eventPrefix = 'signifyd_case';
  23. /**
  24. * @var SerializerInterface
  25. */
  26. private $serializer;
  27. /**
  28. * CaseEntity constructor.
  29. *
  30. * @param Context $context
  31. * @param Registry $registry
  32. * @param SerializerInterface $serializer
  33. * @param array $data
  34. * @param AbstractResource|null $resource
  35. * @param AbstractDb|null $resourceCollection
  36. */
  37. public function __construct(
  38. Context $context,
  39. Registry $registry,
  40. SerializerInterface $serializer,
  41. array $data = [],
  42. AbstractResource $resource = null,
  43. AbstractDb $resourceCollection = null
  44. ) {
  45. $this->serializer = $serializer;
  46. parent::__construct($context, $registry, $resource, $resourceCollection, $data);
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. protected function _construct()
  52. {
  53. $this->_init(ResourceModel\CaseEntity::class);
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public function getEntityId()
  59. {
  60. return (int) $this->getData('entity_id');
  61. }
  62. /**
  63. * @inheritdoc
  64. */
  65. public function setEntityId($id)
  66. {
  67. $this->setData('entity_id', (int) $id);
  68. return $this;
  69. }
  70. /**
  71. * @inheritdoc
  72. */
  73. public function getCaseId()
  74. {
  75. return (int) $this->getData('case_id');
  76. }
  77. /**
  78. * @inheritdoc
  79. */
  80. public function setCaseId($id)
  81. {
  82. $this->setData('case_id', (int) $id);
  83. return $this;
  84. }
  85. /**
  86. * @inheritdoc
  87. */
  88. public function isGuaranteeEligible()
  89. {
  90. $value = $this->getData('guarantee_eligible');
  91. return ($value === null) ? $value : (bool) $value;
  92. }
  93. /**
  94. * @inheritdoc
  95. */
  96. public function setGuaranteeEligible($guaranteeEligible)
  97. {
  98. $this->setData('guarantee_eligible', $guaranteeEligible);
  99. return $this;
  100. }
  101. /**
  102. * @inheritdoc
  103. */
  104. public function getGuaranteeDisposition()
  105. {
  106. return (string) $this->getData('guarantee_disposition');
  107. }
  108. /**
  109. * @inheritdoc
  110. */
  111. public function setGuaranteeDisposition($disposition)
  112. {
  113. $this->setData('guarantee_disposition', (string) $disposition);
  114. return $this;
  115. }
  116. /**
  117. * @inheritdoc
  118. */
  119. public function getStatus()
  120. {
  121. return (string) $this->getData('status');
  122. }
  123. /**
  124. * @inheritdoc
  125. */
  126. public function setStatus($status)
  127. {
  128. $this->setData('status', (string) $status);
  129. return $this;
  130. }
  131. /**
  132. * @inheritdoc
  133. */
  134. public function getScore()
  135. {
  136. return (int) $this->getData('score');
  137. }
  138. /**
  139. * @inheritdoc
  140. */
  141. public function setScore($score)
  142. {
  143. $this->setData('score', (int) $score);
  144. return $this;
  145. }
  146. /**
  147. * @inheritdoc
  148. */
  149. public function getOrderId()
  150. {
  151. return (int) $this->getData('order_id');
  152. }
  153. /**
  154. * @inheritdoc
  155. */
  156. public function setOrderId($orderId)
  157. {
  158. $this->setData('order_id', (int) $orderId);
  159. return $this;
  160. }
  161. /**
  162. * @inheritdoc
  163. */
  164. public function getAssociatedTeam()
  165. {
  166. $teamData = $this->getData('associated_team');
  167. return empty($teamData) ? [] : $this->serializer->unserialize($teamData);
  168. }
  169. /**
  170. * @inheritdoc
  171. */
  172. public function setAssociatedTeam(array $team)
  173. {
  174. $this->setData('associated_team', $this->serializer->serialize($team));
  175. return $this;
  176. }
  177. /**
  178. * @inheritdoc
  179. */
  180. public function getReviewDisposition()
  181. {
  182. return (string) $this->getData('review_disposition');
  183. }
  184. /**
  185. * @inheritdoc
  186. */
  187. public function setReviewDisposition($disposition)
  188. {
  189. $this->setData('review_disposition', (string) $disposition);
  190. return $this;
  191. }
  192. /**
  193. * @inheritdoc
  194. */
  195. public function getCreatedAt()
  196. {
  197. return $this->getData('created_at');
  198. }
  199. /**
  200. * @inheritdoc
  201. */
  202. public function setCreatedAt($datetime)
  203. {
  204. $this->setData('created_at', $datetime);
  205. return $this;
  206. }
  207. /**
  208. * @inheritdoc
  209. */
  210. public function getUpdatedAt()
  211. {
  212. return $this->getData('updated_at');
  213. }
  214. /**
  215. * @inheritdoc
  216. */
  217. public function setUpdatedAt($datetime)
  218. {
  219. $this->setData('updated_at', $datetime);
  220. return $this;
  221. }
  222. }