Skip to content

Commit

Permalink
Rename credit memo allocation to credit memo invoice allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyd Bueno de Mesquita committed Sep 6, 2022
1 parent 6cd1f9b commit 65c6d7d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @method Services\CustomerService customers()
* @method Services\InvoiceItemService invoiceItems()
* @method Services\CreditMemoAllocationService creditMemoAllocations()
* @method Services\CreditMemoInvoiceAllocationService creditMemoInvoiceAllocations()
* @method Services\InvoiceService invoices()
* @method Services\CreditMemoService creditMemos()
* @method Services\PaymentCardService paymentCards()
Expand Down Expand Up @@ -114,7 +115,7 @@ final class Client
'customerCredentials' => Services\CustomerCredentialService::class,
'customers' => Services\CustomerService::class,
'invoiceItems' => Services\InvoiceItemService::class,
'creditMemoAllocations' => Services\CreditMemoAllocationService::class,
'creditMemoInvoiceAllocations' => Services\CreditMemoInvoiceAllocationService::class,
'invoices' => Services\InvoiceService::class,
'creditMemos' => Services\CreditMemoService::class,
'paymentCards' => Services\PaymentCardService::class,
Expand Down
70 changes: 70 additions & 0 deletions src/Entities/CreditMemoInvoiceAllocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 CreditMemoInvoiceAllocation.
*/
final class CreditMemoInvoiceAllocation extends Entity
{
/**
* @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 getInvoiceId()
{
return $this->getAttribute('invoiceId');
}

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

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

/**
* @return string
*/
public function getCreatedTime()
{
return $this->getAttribute('createdTime');
}
}
4 changes: 2 additions & 2 deletions src/Entities/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ public function __construct()
return new InvoiceItem($content);
},
'invoices/{invoiceId}/credit-memo-allocations' => function (array $content) {
return new Collection(new CreditMemoAllocation(), $content);
return new Collection(new CreditMemoInvoiceAllocation(), $content);
},
'invoices/{invoiceId}/credit-memo-allocations/{creditMemoId}' => function (array $content) {
return new CreditMemoAllocation($content);
return new CreditMemoInvoiceAllocation($content);
},
'invoices/{invoiceId}/lead-source' => function (array $content) {
return new LeadSource($content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

use ArrayObject;
use JsonSerializable;
use Rebilly\Entities\CreditMemoAllocation;
use Rebilly\Entities\CreditMemoInvoiceAllocation;
use Rebilly\Http\Exception\DataValidationException;
use Rebilly\Http\Exception\NotFoundException;
use Rebilly\Paginator;
use Rebilly\Rest\Collection;
use Rebilly\Rest\Service;

/**
* Class CreditMemoAllocationService.
* Class CreditMemoInvoiceAllocationService.
*/
final class CreditMemoAllocationService extends Service
final class CreditMemoInvoiceAllocationService extends Service
{
/**
* @param string $invoiceId
* @param array|ArrayObject $params
*
* @return CreditMemoAllocation[][]|Collection[]|Paginator
* @return CreditMemoInvoiceAllocation[][]|Collection[]|Paginator
*/
public function paginator($invoiceId, $params = [])
{
Expand All @@ -44,7 +44,7 @@ public function paginator($invoiceId, $params = [])
* @param string $invoiceId
* @param array|ArrayObject $params
*
* @return CreditMemoAllocation[]|Collection
* @return CreditMemoInvoiceAllocation[]|Collection
*/
public function search($invoiceId, $params = [])
{
Expand All @@ -58,9 +58,9 @@ public function search($invoiceId, $params = [])
* @param string $invoiceId
* @param string $creditMemoId
*
* @throws NotFoundException if resource does not exist
* @return CreditMemoInvoiceAllocation
*@throws NotFoundException if resource does not exist
*
* @return CreditMemoAllocation
*/
public function load($invoiceId, $creditMemoId)
{
Expand All @@ -73,11 +73,11 @@ public function load($invoiceId, $creditMemoId)
/**
* @param string $invoiceId
* @param string $creditMemoId
* @param array|JsonSerializable|CreditMemoAllocation $data
* @param array|JsonSerializable|CreditMemoInvoiceAllocation $data
*
* @throws DataValidationException if input data is not valid
* @return CreditMemoInvoiceAllocation
*@throws DataValidationException if input data is not valid
*
* @return CreditMemoAllocation
*/
public function update($invoiceId, $creditMemoId, $data)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Api/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function provideEntityClasses(): iterable
[Entities\CustomerCredential::class],
[Entities\File::class],
[Entities\CreditMemo::class],
[Entities\CreditMemoAllocation::class],
[Entities\CreditMemoInvoiceAllocation::class],
[Entities\Invoice::class],
[Entities\InvoiceItem::class],
[Entities\PaymentMethods\PaymentCardMethod::class, null],
Expand Down
16 changes: 8 additions & 8 deletions tests/Api/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function invoiceItemService()
/**
* @test
*/
public function creditMemoAllocationsService()
public function creditMemoInvoiceAllocationsService()
{
$client = new Client(['apiKey' => 'QWERTY']);

Expand All @@ -423,8 +423,8 @@ public function creditMemoAllocationsService()
'httpHandler' => $handler,
]);

$service = $client->creditMemoAllocations();
self::assertInstanceOf(Services\CreditMemoAllocationService::class, $service);
$service = $client->creditMemoInvoiceAllocations();
self::assertInstanceOf(Services\CreditMemoInvoiceAllocationService::class, $service);

$paginator = $service->paginator('invoiceId');
self::assertInstanceOf(Paginator::class, $paginator);
Expand All @@ -433,10 +433,10 @@ public function creditMemoAllocationsService()
self::assertInstanceOf(Rest\Collection::class, $result);

$result = $service->load('invoiceId', 'dummy');
self::assertInstanceOf(Entities\CreditMemoAllocation::class, $result);
self::assertInstanceOf(Entities\CreditMemoInvoiceAllocation::class, $result);

$result = $service->update('invoiceId', 'dummy', []);
self::assertInstanceOf(Entities\CreditMemoAllocation::class, $result);
self::assertInstanceOf(Entities\CreditMemoInvoiceAllocation::class, $result);

$service->delete('invoiceId', 'dummy');
}
Expand Down Expand Up @@ -1208,9 +1208,9 @@ public function provideServiceClasses()
Entities\Invoice::class,
],
[
'creditMemoAllocations',
Services\CreditMemoAllocationService::class,
Entities\CreditMemoAllocation::class,
'creditMemoInvoiceAllocations',
Services\CreditMemoInvoiceAllocationService::class,
Entities\CreditMemoInvoiceAllocation::class,
],
[
'creditMemos',
Expand Down

0 comments on commit 65c6d7d

Please sign in to comment.