diff --git a/src/Resources/Adjustments/Operations/CreateAdjustment.php b/src/Resources/Adjustments/Operations/CreateAdjustment.php index 45f227c..f969ae9 100644 --- a/src/Resources/Adjustments/Operations/CreateAdjustment.php +++ b/src/Resources/Adjustments/Operations/CreateAdjustment.php @@ -38,6 +38,16 @@ public function __construct( } } + public static function full(Action $action, string $reason, string $transactionId): self + { + return new self($action, new Undefined(), $reason, $transactionId, AdjustmentType::Full()); + } + + public static function partial(Action $action, array $items, string $reason, string $transactionId): self + { + return new self($action, $items, $reason, $transactionId, AdjustmentType::Partial()); + } + public function jsonSerialize(): array { if (is_array($this->items)) { diff --git a/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php b/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php index 4ed5fdb..dfe5245 100644 --- a/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php +++ b/tests/Functional/Resources/Adjustments/AdjustmentsClientTest.php @@ -19,7 +19,6 @@ use Paddle\SDK\Resources\Adjustments\Operations\ListAdjustments; use Paddle\SDK\Resources\Shared\Operations\List\Pager; use Paddle\SDK\Tests\Utils\ReadsFixtures; -use Paddle\SDK\Undefined; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -103,7 +102,7 @@ public static function createOperationsProvider(): \Generator ]; yield 'Partial type with items' => [ - new CreateAdjustment( + CreateAdjustment::partial( Action::Refund(), [new AdjustmentItem( 'txnitm_01h8bxryv3065dyh6103p3yg28', @@ -112,19 +111,16 @@ public static function createOperationsProvider(): \Generator )], 'error', 'txn_01h8bxpvx398a7zbawb77y0kp5', - \Paddle\SDK\Entities\Adjustment\AdjustmentType::Partial(), ), new Response(200, body: self::readRawJsonFixture('response/minimal_entity')), self::readRawJsonFixture('request/create_type_partial_with_items'), ]; yield 'Full type with no items' => [ - new CreateAdjustment( + CreateAdjustment::full( Action::Refund(), - new Undefined(), 'error', 'txn_01h8bxpvx398a7zbawb77y0kp5', - \Paddle\SDK\Entities\Adjustment\AdjustmentType::Full(), ), new Response(200, body: self::readRawJsonFixture('response/minimal_entity')), self::readRawJsonFixture('request/create_type_full_with_no_items'),