Skip to content

Commit

Permalink
Merge pull request #150 from ryall/master
Browse files Browse the repository at this point in the history
Support DateTime inputs as well as string. Add validation for require…
  • Loading branch information
delatbabel authored Oct 18, 2016
2 parents 942d616 + a4cbbe9 commit 0f894c6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Message/RestSearchTransactionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ public function getStartDate()
/**
* Set the request startDate
*
* @param string $value
* @param string|DateTime $value
* @return RestSearchTransactionRequest provides a fluent interface.
*/
public function setStartDate($value)
{
return $this->setParameter('startDate', $value);
return $this->setParameter('startDate', is_string($value) ? new \DateTime($value) : $value);
}

/**
Expand All @@ -161,20 +161,20 @@ public function getEndDate()
/**
* Set the request endDate
*
* @param string $value
* @param string|DateTime $value
* @return RestSearchTransactionRequest provides a fluent interface.
*/
public function setEndDate($value)
{
return $this->setParameter('endDate', $value);
return $this->setParameter('endDate', is_string($value) ? new \DateTime($value) : $value);
}

public function getData()
{
$this->validate('agreementId');
$this->validate('agreementId', 'startDate', 'endDate');
return array(
'start_date' => $this->getStartDate(),
'end_date' => $this->getEndDate(),
'start_date' => $this->getStartDate()->format('Y-m-d'),
'end_date' => $this->getEndDate()->format('Y-m-d'),
);
}

Expand Down

0 comments on commit 0f894c6

Please sign in to comment.