-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Transaction Preview Price #89
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d970ca4
fix: Separate transaction preview operations and nullable preview pri…
davidgrayston-paddle f983c60
fix: Add TransactionPreviewPrice with nullable ID
davidgrayston-paddle 0b39445
fix Add support for transaction update items with optional properties
davidgrayston-paddle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities\Transaction; | ||
|
||
use Paddle\SDK\Entities\DateTime; | ||
use Paddle\SDK\Entities\Entity; | ||
use Paddle\SDK\Entities\Product; | ||
use Paddle\SDK\Entities\Shared\CatalogType; | ||
use Paddle\SDK\Entities\Shared\CustomData; | ||
use Paddle\SDK\Entities\Shared\ImportMeta; | ||
use Paddle\SDK\Entities\Shared\Money; | ||
use Paddle\SDK\Entities\Shared\PriceQuantity; | ||
use Paddle\SDK\Entities\Shared\Status; | ||
use Paddle\SDK\Entities\Shared\TaxMode; | ||
use Paddle\SDK\Entities\Shared\TimePeriod; | ||
use Paddle\SDK\Entities\Shared\UnitPriceOverride; | ||
|
||
class TransactionPreviewPrice implements Entity | ||
{ | ||
/** | ||
* @param array<UnitPriceOverride> $unitPriceOverrides | ||
*/ | ||
private function __construct( | ||
public string|null $id, | ||
public string $productId, | ||
public string|null $name, | ||
public string $description, | ||
public CatalogType|null $type, | ||
public TimePeriod|null $billingCycle, | ||
public TimePeriod|null $trialPeriod, | ||
public TaxMode $taxMode, | ||
public Money $unitPrice, | ||
public array $unitPriceOverrides, | ||
public PriceQuantity $quantity, | ||
public Status $status, | ||
public CustomData|null $customData, | ||
public ImportMeta|null $importMeta, | ||
public Product|null $product, | ||
public \DateTimeInterface $createdAt, | ||
public \DateTimeInterface $updatedAt, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
id: $data['id'], | ||
productId: $data['product_id'], | ||
name: $data['name'] ?? null, | ||
description: $data['description'], | ||
type: CatalogType::from($data['type'] ?? ''), | ||
billingCycle: isset($data['billing_cycle']) ? TimePeriod::from($data['billing_cycle']) : null, | ||
trialPeriod: isset($data['trial_period']) ? TimePeriod::from($data['trial_period']) : null, | ||
taxMode: TaxMode::from($data['tax_mode']), | ||
unitPrice: Money::from($data['unit_price']), | ||
unitPriceOverrides: array_map( | ||
fn (array $override): UnitPriceOverride => UnitPriceOverride::from($override), | ||
$data['unit_price_overrides'] ?? [], | ||
), | ||
quantity: PriceQuantity::from($data['quantity']), | ||
status: Status::from($data['status']), | ||
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null, | ||
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null, | ||
product: isset($data['product']) ? Product::from($data['product']) : null, | ||
createdAt: DateTime::from($data['created_at']), | ||
updatedAt: DateTime::from($data['updated_at']), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Resources/Transactions/Operations/Create/TransactionCreateItem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paddle\SDK\Resources\Transactions\Operations\Create; | ||
|
||
class TransactionCreateItem | ||
{ | ||
public function __construct( | ||
public string $priceId, | ||
public int $quantity, | ||
) { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Resources/Transactions/Operations/Create/TransactionCreateItemWithPrice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paddle\SDK\Resources\Transactions\Operations\Create; | ||
|
||
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice; | ||
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct; | ||
|
||
class TransactionCreateItemWithPrice | ||
{ | ||
public function __construct( | ||
public TransactionNonCatalogPrice|TransactionNonCatalogPriceWithProduct $price, | ||
public int $quantity, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Resources/Transactions/Operations/Preview/TransactionItemPreviewWithNonCatalogPrice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paddle\SDK\Resources\Transactions\Operations\Preview; | ||
|
||
use Paddle\SDK\FiltersUndefined; | ||
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPrice; | ||
use Paddle\SDK\Resources\Transactions\Operations\Price\TransactionNonCatalogPriceWithProduct; | ||
use Paddle\SDK\Undefined; | ||
|
||
class TransactionItemPreviewWithNonCatalogPrice implements \JsonSerializable | ||
{ | ||
use FiltersUndefined; | ||
|
||
public function __construct( | ||
public TransactionNonCatalogPrice|TransactionNonCatalogPriceWithProduct $price, | ||
public int $quantity, | ||
public bool|Undefined $includeInTotals = new Undefined(), | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return $this->filterUndefined([ | ||
'price' => $this->price, | ||
'quantity' => $this->quantity, | ||
'include_in_totals' => $this->includeInTotals, | ||
]); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Resources/Transactions/Operations/Preview/TransactionItemPreviewWithPriceId.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Paddle\SDK\Resources\Transactions\Operations\Preview; | ||
|
||
use Paddle\SDK\FiltersUndefined; | ||
use Paddle\SDK\Undefined; | ||
|
||
class TransactionItemPreviewWithPriceId implements \JsonSerializable | ||
{ | ||
use FiltersUndefined; | ||
|
||
public function __construct( | ||
public string $priceId, | ||
public int $quantity, | ||
public bool|Undefined $includeInTotals = new Undefined(), | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return $this->filterUndefined([ | ||
'price_id' => $this->priceId, | ||
'quantity' => $this->quantity, | ||
'include_in_totals' => $this->includeInTotals, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this
TransactionPreviewPrice
only?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just
TransactionPreviewPrice
would make it breaking so lets stick with the union 👍