Skip to content

Commit

Permalink
Add transaction allocations to credit memo
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyd Bueno de Mesquita committed Sep 18, 2022
1 parent 6cd1f9b commit 6ec1783
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 0 deletions.
146 changes: 146 additions & 0 deletions src/Entities/AllocationCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Entities;

use Rebilly\Rest\Entity;

/**
* Class AllocationCollection.
*/
final class AllocationCollection extends Entity
{
/**
* @return TransactionAllocation[]
*/
public function getTransactions()
{
return $this->getAttribute('transactions');
}

/**
* @param TransactionAllocation[] $value
*
* @return $this
*/
public function setTransactions($value)
{
return $this->setAttribute('transactions', $value);
}

/**
* @param float $value
*
* @return $this
*/
public function setUnitPrice($value)
{
return $this->setAttribute('unitPrice', $value);
}

/**
* @return int
*/
public function getQuantity()
{
return $this->getAttribute('quantity');
}

/**
* @param int $value
*
* @return $this
*/
public function setQuantity($value)
{
return $this->setAttribute('quantity', $value);
}

/**
* @return string|null
*/
public function getInvoiceItemId()
{
return $this->getAttribute('invoiceItemId');
}

/**
* @param string|null $value
*
* @return $this
*/
public function setInvoiceItemId($value)
{
return $this->setAttribute('invoiceItemId', $value);
}

/**
* @return string
*/
public function getDescription()
{
return $this->getAttribute('description');
}

/**
* @param string $value
*
* @return $this
*/
public function setDescription($value)
{
return $this->setAttribute('description', $value);
}

/**
* @return float
*/
public function getPrice()
{
return $this->getAttribute('price');
}

/**
* @return string|null
*/
public function getProductId()
{
return $this->getAttribute('productId');
}

/**
* @param string|null $value
*
* @return $this
*/
public function setProductId($value)
{
return $this->setAttribute('productId', $value);
}

/**
* @return string|null
*/
public function getPlanId()
{
return $this->getAttribute('planId');
}

/**
* @param string|null $value
*
* @return $this
*/
public function setPlanId($value)
{
return $this->setAttribute('planId', $value);
}
}
18 changes: 18 additions & 0 deletions src/Entities/CreditMemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,24 @@ public function getUnusedAmount()
return $this->getAttribute('unusedAmount');
}

/**
* @return AllocationCollection
*/
public function getAllocations()
{
return $this->getAttribute('allocations');
}

/**
* @param AllocationCollection $value
*
* @return $this
*/
public function setAllocations($value)
{
return $this->setAttribute('allocations', $value);
}

/**
* @return int
*/
Expand Down
88 changes: 88 additions & 0 deletions src/Entities/TransactionAllocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Entities;

use Rebilly\Rest\Entity;

/**
* Class TransactionAllocation.
*/
final class TransactionAllocation extends Entity
{
/**
* @return string
*/
public function getCreditMemoId()
{
return $this->getAttribute('creditMemoId');
}

/**
* @return string
*/
public function getTransactionId()
{
return $this->getAttribute('transactionId');
}

/**
* @param string
*
* @return $this
*/
public function setTransactionId($value)
{
return $this->setAttribute('transactionId', $value);
}

/**
* @return float
*/
public function getAmount()
{
return $this->getAttribute('amount');
}

/**
* @param float $value
*
* @return $this
*/
public function setAmount($value)
{
return $this->setAttribute('amount', $value);
}

/**
* @return string
*/
public function getCurrency()
{
return $this->getAttribute('currency');
}

/**
* @return string
*/
public function getCreatedTime()
{
return $this->getAttribute('createdTime');
}

/**
* @return string
*/
public function getUpdatedTime()
{
return $this->getAttribute('updatedTime');
}
}
4 changes: 4 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,10 @@ protected function getFakeValue($attribute, $class)
sprintf('Cannot generate fake value for "%s :: %s"', $class, $attribute)
);
}
case 'allocations':
return new Entities\AllocationCollection(['transactions' => [new Entities\TransactionAllocation([
'transactionId' => 'transaction-1',
])]]);
}
}

Expand Down

0 comments on commit 6ec1783

Please sign in to comment.