1: <?php
2: namespace Hyperwallet\Model;
3:
4: /**
5: * Represents a V4 Webhook Notification
6: *
7: * @property string $token The webhook notification token
8: * @property string $type The webhook notification type
9: * @property \DateTime $createdOn The webhook notification creation date
10: *
11: * @package Hyperwallet\Model
12: */
13: class WebhookNotification extends BaseModel {
14:
15: /**
16: * The webhook notification payload
17: *
18: * @var object
19: */
20: private $object;
21:
22: /**
23: * @internal
24: *
25: * Read only fields
26: *
27: * @var string[]
28: */
29: private static $READ_ONLY_FIELDS = array('token', 'type', 'createdOn');
30:
31: public static function FILTERS_ARRAY() {
32: return array('programToken', 'type', 'createdBefore', 'createdAfter', 'sortBy', 'limit');
33: }
34:
35: /**
36: * Creates a instance of WebhookNotification
37: *
38: * @param string[] $properties The default properties
39: */
40: public function __construct(array $properties = array()) {
41: parent::__construct(self::$READ_ONLY_FIELDS, $properties);
42:
43: $this->object = null;
44: if (isset($properties['type'])) {
45: if (strpos($properties['type'], 'USERS.BANK_ACCOUNTS') === 0) {
46: $this->object = new BankAccount($properties['object']);
47: } else if (strpos($properties['type'], 'USERS.PREPAID_CARDS') === 0) {
48: $this->object = new PrepaidCard($properties['object']);
49: } else if (strpos($properties['type'], 'USERS.PAYPAL_ACCOUNTS') === 0) {
50: $this->object = new PayPalAccount($properties['object']);
51: } else if (strpos($properties['type'], 'USERS.VENMO_ACCOUNTS') === 0) {
52: $this->object = new VenmoAccount($properties['object']);
53: } else if (strpos($properties['type'], 'USERS.BANK_CARDS') === 0) {
54: $this->object = new BankCard($properties['object']);
55: } else if (strpos($properties['type'], 'USERS.BUSINESS_STAKEHOLDERS') === 0) {
56: $this->object = new BusinessStakeholder($properties['object']);
57: } else if (strpos($properties['type'], 'USERS.PAPER_CHECKS') === 0) {
58: $this->object = new PaperCheck($properties['object']);
59: } else if (strpos($properties['type'], 'USERS') === 0) {
60: $this->object = new User($properties['object']);
61: } else if (strpos($properties['type'], 'PAYMENTS') === 0) {
62: $this->object = new Payment($properties['object']);
63: } else if (strpos($properties['type'], 'TRANSFERS.REFUND') === 0) {
64: $this->object = new TransferRefund($properties['object']);
65: } else if (strpos($properties['type'], 'TRANSFERS') === 0) {
66: $this->object = new Transfer($properties['object']);
67: }
68: }
69: }
70:
71: /**
72: * Get the webhook notification token
73: *
74: * @return string
75: */
76: public function getToken() {
77: return $this->token;
78: }
79:
80: /**
81: * Get the webhook notification type
82: *
83: * @return string
84: */
85: public function getType() {
86: return $this->type;
87: }
88:
89: /**
90: * Get the webhook notification creation date
91: *
92: * @return \DateTime
93: */
94: public function getCreatedOn() {
95: return $this->createdOn ? new \DateTime($this->createdOn) : null;
96: }
97:
98: /**
99: * Get the webhook notification payload
100: *
101: * @return BankAccount|PrepaidCard|User|Payment|null
102: */
103: public function getObject() {
104: return $this->object;
105: }
106:
107: }
108: