1: <?php
2:
3: /**
4: * A subscription event object
5: */
6: class Syspay_Merchant_Entity_SubscriptionEvent extends Syspay_Merchant_Entity implements
7: Syspay_Merchant_Entity_ReturnedEntityInterface
8: {
9: const TYPE = 'subscription_event';
10:
11: const TYPE_TRIAL = 'TRIAL';
12: const TYPE_FREE_TRIAL = 'FREE_TRIAL';
13: const TYPE_INITIAL = 'INITIAL';
14: const TYPE_BILL = 'BILL';
15: const TYPE_END = 'END';
16:
17: /**
18: * @var DateTime
19: */
20: protected $scheduledDate;
21:
22: /**
23: * @var string
24: */
25: protected $eventType;
26:
27: /**
28: * Build an event entity based on a json-decoded event stdClass
29: *
30: * @param stdClass $response The subscription event
31: * @return Syspay_Merchant_Entity_SubscriptionEvent The event object
32: */
33: public static function buildFromResponse(stdClass $response)
34: {
35: $event = new self();
36: $event->setScheduledDate(
37: isset($response->scheduled_date)?Syspay_Merchant_Utils::tsToDateTime($response->scheduled_date):null
38: );
39: $event->setEventType(isset($response->event_type)?$response->event_type:null);
40:
41: $event->raw = $response;
42:
43: return $event;
44: }
45:
46: /**
47: * Gets the value of scheduledDate.
48: *
49: * @return DateTime
50: */
51: public function getScheduledDate()
52: {
53: return $this->scheduledDate;
54: }
55:
56: /**
57: * Sets the value of scheduledDate.
58: *
59: * @param DateTime $scheduledDate the scheduled date
60: *
61: * @return self
62: */
63: public function setScheduledDate(DateTime $scheduledDate = null)
64: {
65: $this->scheduledDate = $scheduledDate;
66:
67: return $this;
68: }
69:
70: /**
71: * Gets the value of eventType.
72: *
73: * @return string
74: */
75: public function getEventType()
76: {
77: return $this->eventType;
78: }
79:
80: /**
81: * Sets the value of eventType.
82: *
83: * @param string $eventType the event type
84: *
85: * @return self
86: */
87: public function setEventType($eventType)
88: {
89: $this->eventType = $eventType;
90:
91: return $this;
92: }
93: }
94: