Skip to content

Commit 0f894c6

Browse files
authored
Merge pull request #150 from ryall/master
Support DateTime inputs as well as string. Add validation for require…
2 parents 942d616 + a4cbbe9 commit 0f894c6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Message/RestSearchTransactionRequest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ public function getStartDate()
140140
/**
141141
* Set the request startDate
142142
*
143-
* @param string $value
143+
* @param string|DateTime $value
144144
* @return RestSearchTransactionRequest provides a fluent interface.
145145
*/
146146
public function setStartDate($value)
147147
{
148-
return $this->setParameter('startDate', $value);
148+
return $this->setParameter('startDate', is_string($value) ? new \DateTime($value) : $value);
149149
}
150150

151151
/**
@@ -161,20 +161,20 @@ public function getEndDate()
161161
/**
162162
* Set the request endDate
163163
*
164-
* @param string $value
164+
* @param string|DateTime $value
165165
* @return RestSearchTransactionRequest provides a fluent interface.
166166
*/
167167
public function setEndDate($value)
168168
{
169-
return $this->setParameter('endDate', $value);
169+
return $this->setParameter('endDate', is_string($value) ? new \DateTime($value) : $value);
170170
}
171171

172172
public function getData()
173173
{
174-
$this->validate('agreementId');
174+
$this->validate('agreementId', 'startDate', 'endDate');
175175
return array(
176-
'start_date' => $this->getStartDate(),
177-
'end_date' => $this->getEndDate(),
176+
'start_date' => $this->getStartDate()->format('Y-m-d'),
177+
'end_date' => $this->getEndDate()->format('Y-m-d'),
178178
);
179179
}
180180

0 commit comments

Comments
 (0)