Skip to content

Commit

Permalink
Allow access upcoming invoice from Subscription (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirRebilly authored Apr 21, 2022
1 parent 58f548a commit 43a9a70
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Security - in case of vulnerabilities.

_TBD_

## [2.18.0] 2022-04-21

### Added

- [x] Added `Subscription::getUpcomingInvoice()` method

## [2.17.0] 2022-04-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class Client
*/
public const CURRENT_VERSION = 'v2.1';

public const SDK_VERSION = '2.17.0';
public const SDK_VERSION = '2.18.0';

private static $services = [
'authenticationOptions' => Services\AuthenticationOptionsService::class,
Expand Down
12 changes: 12 additions & 0 deletions src/Entities/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ public function getWebsite()
: null;
}

/**
* @return null|Invoice
*/
public function getUpcomingInvoice()
{
$data = $this->getEmbeddedResource('upcomingInvoice');

return $data
? new Invoice($data)
: null;
}

/**
* @return null|Customer
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Entities/Subscriptions/SubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use DateTimeImmutable;
use Rebilly\Entities\Address;
use Rebilly\Entities\Customer;
use Rebilly\Entities\Invoice;
use Rebilly\Entities\LeadSource;
use Rebilly\Entities\PaymentRetryInstructions\ScheduleInstruction;
use Rebilly\Entities\PaymentRetryInstructions\ScheduleInstructionTypes\DateIntervalType;
Expand Down Expand Up @@ -81,6 +82,7 @@ private static function getDefaultData()
'website' => ['id' => 'website-1'],
'customer' => ['id' => 'customer-1'],
'leadSource' => ['id' => 'leadSource-1'],
'upcomingInvoice' => ['id' => 'invoice-1'],
],
];
}
Expand Down Expand Up @@ -187,6 +189,7 @@ public function populatePlanFromArrayReceivedFromServer()
self::assertInstanceOf(Website::class, $value->getWebsite());
self::assertInstanceOf(Customer::class, $value->getCustomer());
self::assertInstanceOf(LeadSource::class, $value->getLeadSource());
self::assertInstanceOf(Invoice::class, $value->getUpcomingInvoice());

$invoiceTimeShift = $value->getInvoiceTimeShift();
self::assertInstanceOf(InvoiceTimeShift::class, $invoiceTimeShift);
Expand Down

0 comments on commit 43a9a70

Please sign in to comment.