Skip to content

Commit 68a7df3

Browse files
committed
Change datetime format
1 parent a3c0f3f commit 68a7df3

File tree

6 files changed

+123
-82
lines changed

6 files changed

+123
-82
lines changed

src/MailQ/Entities/v2/CampaignEntity.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,28 @@ class CampaignEntity extends BaseEntity
5050
public function getCreated()
5151
{
5252
if ($this->created != null) {
53-
return $this->created->format('Y-m-d\TH:i:s.u');
53+
return $this->created->format(DATE_ATOM);
5454
} else {
5555
return null;
5656
}
5757
}
5858

59+
/**
60+
* @return \DateTime
61+
*/
62+
public function getCreatedAsDateTime()
63+
{
64+
return $this->created;
65+
}
66+
5967
/**
6068
* @param $created
6169
* @return $this
6270
*/
6371
public function setCreated($created)
6472
{
6573
if (is_string($created)) {
66-
$this->created = \DateTime::createFromFormat('Y-m-d\TH:i:s.u', $created);
74+
$this->created = \DateTime::createFromFormat(DATE_ATOM, $created);
6775
} elseif ($created instanceof \DateTime) {
6876
$this->created = $created;
6977
}

src/MailQ/Entities/v2/LogMessageEntity.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LogMessageEntity extends BaseEntity
3838
/**
3939
* @in
4040
* @out
41-
* @var string
41+
* @var \DateTime
4242
*/
4343
private $created;
4444

@@ -122,20 +122,36 @@ public function setType($type)
122122
}
123123

124124
/**
125-
* @return string
125+
* @return null|string
126126
*/
127127
public function getCreated()
128+
{
129+
if ($this->created != null) {
130+
return $this->created->format(DATE_ATOM);
131+
} else {
132+
return null;
133+
}
134+
}
135+
136+
/**
137+
* @return \DateTime
138+
*/
139+
public function getCreatedAsDateTime()
128140
{
129141
return $this->created;
130142
}
131143

132144
/**
133-
* @param string $created
145+
* @param $created
134146
* @return LogMessageEntity
135147
*/
136148
public function setCreated($created)
137149
{
138-
$this->created = $created;
150+
if (is_string($created)) {
151+
$this->created = \DateTime::createFromFormat(DATE_ATOM, $created);
152+
} elseif ($created instanceof \DateTime) {
153+
$this->created = $created;
154+
}
139155
return $this;
140156
}
141157

src/MailQ/Entities/v2/NewsletterEntity.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,32 +152,47 @@ class NewsletterEntity extends BaseEntity {
152152
*/
153153
public function getFrom() {
154154
if ($this->from != null) {
155-
return $this->from->format('Y-m-d\TH:i:s.u');
155+
return $this->from->format(DATE_ATOM);
156156
}
157157
else {
158158
return null;
159159
}
160160
}
161161

162+
/**
163+
* @return \DateTime
164+
*/
165+
public function getFromAsDateTime() {
166+
return $this->from;
167+
}
168+
162169
/**
163170
* @return null|string
164171
*/
165172
public function getTo() {
166173
if ($this->to != null) {
167-
return $this->to->format('Y-m-d\TH:i:s.u');
174+
return $this->to->format(DATE_ATOM);
168175
}
169176
else {
170177
return null;
171178
}
172179
}
173180

181+
/**
182+
* @return \DateTime
183+
*/
184+
public function getToAsDateTime() {
185+
return $this->to;
186+
}
187+
174188
/**
175189
* @param $from
176190
* @return NewsletterEntity
177191
*/
178-
public function setFrom($from) {
192+
public function setFrom($from)
193+
{
179194
if (is_string($from)) {
180-
$this->from = \DateTime::createFromFormat('Y-m-d\TH:i:s.u', $from);
195+
$this->from = \DateTime::createFromFormat(DATE_ATOM, $from);
181196
} elseif ($from instanceof \DateTime) {
182197
$this->from = $from;
183198
}
@@ -188,15 +203,17 @@ public function setFrom($from) {
188203
* @param $to
189204
* @return NewsletterEntity
190205
*/
191-
public function setTo($to) {
206+
public function setTo($to)
207+
{
192208
if (is_string($to)) {
193-
$this->to = \DateTime::createFromFormat('Y-m-d\TH:i:s.u', $to);
209+
$this->to = \DateTime::createFromFormat(DATE_ATOM, $to);
194210
} elseif ($to instanceof \DateTime) {
195211
$this->to = $to;
196212
}
197213
return $this;
198214
}
199215

216+
200217
/**
201218
* @return int
202219
*/

src/MailQ/Entities/v2/NotificationDataEntity.php

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,11 @@ class NotificationDataEntity extends BaseEntity {
1414
*/
1515
private $id;
1616
/**
17-
* @in
18-
* @out
19-
* @var integer
20-
*/
21-
private $openedTimestamp;
22-
/**
23-
* @in
24-
* @out
25-
* @var integer
26-
*/
27-
private $undeliveredTimestamp;
28-
/**
29-
* @in
30-
* @out
31-
* @var integer
17+
* @in undeliveredTimestamp
18+
* @out undeliveredTimestamp
19+
* @var \DateTime
3220
*/
33-
private $unsubscribedTimestamp;
21+
private $undelivered;
3422
/**
3523
* @in
3624
* @out
@@ -87,59 +75,37 @@ public function setId($id)
8775
return $this;
8876
}
8977

90-
/**
91-
* @return int
92-
*/
93-
public function getOpenedTimestamp()
94-
{
95-
return $this->openedTimestamp;
96-
}
9778

9879
/**
99-
* @param int $openedTimestamp
100-
* @return NotificationDataEntity
80+
* @return null|string
10181
*/
102-
public function setOpenedTimestamp($openedTimestamp)
82+
public function getUndelivered()
10383
{
104-
$this->openedTimestamp = $openedTimestamp;
105-
return $this;
84+
if ($this->undelivered != null) {
85+
return $this->undelivered->format(DATE_ATOM);
86+
} else {
87+
return null;
88+
}
10689
}
10790

108-
/**
109-
* @return int
110-
*/
111-
public function getUndeliveredTimestamp()
112-
{
113-
return $this->undeliveredTimestamp;
91+
public function getUndeliveredAsDateTime() {
92+
return $this->undelivered;
11493
}
11594

11695
/**
117-
* @param int $undeliveredTimestamp
96+
* @param $undelivered
11897
* @return NotificationDataEntity
11998
*/
120-
public function setUndeliveredTimestamp($undeliveredTimestamp)
99+
public function setUndelivered($undelivered)
121100
{
122-
$this->undeliveredTimestamp = $undeliveredTimestamp;
101+
if (is_string($undelivered)) {
102+
$this->undelivered = \DateTime::createFromFormat(DATE_ATOM, $undelivered);
103+
} elseif ($undelivered instanceof \DateTime) {
104+
$this->undelivered = $undelivered;
105+
}
123106
return $this;
124107
}
125108

126-
/**
127-
* @return int
128-
*/
129-
public function getUnsubscribedTimestamp()
130-
{
131-
return $this->unsubscribedTimestamp;
132-
}
133-
134-
/**
135-
* @param int $unsubscribedTimestamp
136-
* @return NotificationDataEntity
137-
*/
138-
public function setUnsubscribedTimestamp($unsubscribedTimestamp)
139-
{
140-
$this->unsubscribedTimestamp = $unsubscribedTimestamp;
141-
return $this;
142-
}
143109

144110
/**
145111
* @return string

src/MailQ/Entities/v2/SmsEntity.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class SmsEntity extends BaseEntity
3737
private $state;
3838

3939
/**
40-
* @in
41-
* @out
42-
* @var string
40+
* @in sendTimestamp
41+
* @out sendTimestamp
42+
* @var \DateTime
4343
*/
44-
private $sendTimestamp;
44+
private $sent;
4545

4646
/**
4747
* @in
@@ -122,21 +122,39 @@ public function setState($state)
122122
return $this;
123123
}
124124

125+
125126
/**
126-
* @return string
127+
* @return null|string
127128
*/
128-
public function getSendTimestamp()
129+
public function getSent()
129130
{
130-
return $this->sendTimestamp;
131+
if ($this->sent != null) {
132+
return $this->sent->format(DATE_ATOM);
133+
} else {
134+
return null;
135+
}
131136
}
132137

133138
/**
134-
* @param string $sendTimestamp
139+
* @return \DateTime
140+
*/
141+
public function getSentAsDateTime()
142+
{
143+
return $this->sent;
144+
}
145+
146+
147+
/**
148+
* @param $sent
135149
* @return SmsEntity
136150
*/
137-
public function setSendTimestamp($sendTimestamp)
151+
public function setSent($sent)
138152
{
139-
$this->sendTimestamp = $sendTimestamp;
153+
if (is_string($sent)) {
154+
$this->sent = \DateTime::createFromFormat(DATE_ATOM, $sent);
155+
} elseif ($sent instanceof \DateTime) {
156+
$this->sent = $sent;
157+
}
140158
return $this;
141159
}
142160

src/MailQ/Entities/v2/UnsubscriberEntity.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UnsubscriberEntity extends BaseEntity
2525
/**
2626
* @in
2727
* @out
28-
* @var string
28+
* @var \DateTime
2929
*/
3030
private $unsubscribed;
3131

@@ -85,22 +85,38 @@ public function setEmail($email)
8585
$this->email = $email;
8686
return $this;
8787
}
88-
88+
8989
/**
90-
* @return string
90+
* @return null|string
9191
*/
9292
public function getUnsubscribed()
9393
{
94+
if ($this->unsubscribed != null) {
95+
return $this->unsubscribed->format(DATE_ATOM);
96+
} else {
97+
return null;
98+
}
99+
}
100+
101+
/**
102+
* @return \DateTime
103+
*/
104+
public function getUnsubscribedAsDateTime() {
94105
return $this->unsubscribed;
95106
}
96107

108+
97109
/**
98-
* @param string $unsubscribed
99-
* @return UnsubscriberEntity
110+
* @param $unsubscribed
111+
* @return NotificationDataEntity
100112
*/
101113
public function setUnsubscribed($unsubscribed)
102114
{
103-
$this->unsubscribed = $unsubscribed;
115+
if (is_string($unsubscribed)) {
116+
$this->unsubscribed = \DateTime::createFromFormat(DATE_ATOM, $unsubscribed);
117+
} elseif ($unsubscribed instanceof \DateTime) {
118+
$this->unsubscribed = $unsubscribed;
119+
}
104120
return $this;
105121
}
106122

0 commit comments

Comments
 (0)