Skip to content

Commit

Permalink
Update Refund.php to reflect optional tender_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
eyw520 committed Jan 6, 2025
1 parent 8b67550 commit 37f71b1
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/Models/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class Refund implements \JsonSerializable
private $transactionId = [];

/**
* @var string
* @var array
*/
private $tenderId;
private $tenderId = [];

/**
* @var string|null
Expand Down Expand Up @@ -64,22 +64,20 @@ class Refund implements \JsonSerializable
/**
* @param string $id
* @param string $locationId
* @param string $tenderId
* @param string|null $tenderId
* @param string $reason
* @param Money $amountMoney
* @param string $status
*/
public function __construct(
string $id,
string $locationId,
string $tenderId,
string $reason,
Money $amountMoney,
string $status
) {
$this->id = $id;
$this->locationId = $locationId;
$this->tenderId = $tenderId;
$this->reason = $reason;
$this->amountMoney = $amountMoney;
$this->status = $status;
Expand Down Expand Up @@ -163,21 +161,32 @@ public function unsetTransactionId(): void
* Returns Tender Id.
* The ID of the refunded tender.
*/
public function getTenderId(): string
public function getTenderId(): ?string
{
return $this->tenderId;
if (count($this->tenderId) == 0) {
return null;
}
return $this->tenderId['value'];
}

/**
* Sets Tender Id.
* The ID of the refunded tender.
*
* @required
* @maps tender_id
*/
public function setTenderId(string $tenderId): void
public function setTenderId(?string $tenderId): void
{
$this->tenderId['value'] = $tenderId;
}

/**
* Unsets Tender Id.
* The ID of the refunded tender.
*/
public function unsetTenderId(): void
{
$this->tenderId = $tenderId;
$this->tenderId = [];
}

/**
Expand Down Expand Up @@ -363,7 +372,9 @@ public function jsonSerialize(bool $asArrayWhenEmpty = false)
if (!empty($this->transactionId)) {
$json['transaction_id'] = $this->transactionId['value'];
}
$json['tender_id'] = $this->tenderId;
if (!empty($this->tenderId)) {
$json['tender_id'] = $this->tenderId['value'];
}
if (isset($this->createdAt)) {
$json['created_at'] = $this->createdAt;
}
Expand Down

0 comments on commit 37f71b1

Please sign in to comment.