Skip to content
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

CreateDiscount and UpdateDiscount Ops are missing Custom Data #57 #58

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Entities/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

namespace Paddle\SDK\Entities;

use Paddle\SDK\Entities\Discount\DiscountStatus;
use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\ImportMeta;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Discount\DiscountStatus;
dutypro marked this conversation as resolved.
Show resolved Hide resolved

class Discount implements Entity
{
Expand All @@ -35,6 +36,7 @@ private function __construct(
public int $timesUsed,
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
public CustomData|null $customData,
public ImportMeta|null $importMeta,
) {
}
Expand All @@ -58,6 +60,7 @@ public static function from(array $data): self
timesUsed: $data['times_used'],
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/Resources/Discounts/Operations/CreateDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace Paddle\SDK\Resources\Discounts\Operations;

use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Discount\DiscountType;
dutypro marked this conversation as resolved.
Show resolved Hide resolved

class CreateDiscount implements \JsonSerializable
{
Expand All @@ -28,6 +29,7 @@ public function __construct(
public readonly int|Undefined|null $usageLimit = new Undefined(),
public readonly array|Undefined|null $restrictTo = new Undefined(),
public readonly string|Undefined|null $expiresAt = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand All @@ -45,6 +47,7 @@ public function jsonSerialize(): array
'usage_limit' => $this->usageLimit,
'restrict_to' => $this->restrictTo,
'expires_at' => $this->expiresAt,
'custom_data' => $this->customData,
]);
}
}
11 changes: 7 additions & 4 deletions src/Resources/Discounts/Operations/UpdateDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace Paddle\SDK\Resources\Discounts\Operations;

use Paddle\SDK\Entities\Discount\DiscountStatus;
use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Discount\DiscountStatus;
dutypro marked this conversation as resolved.
Show resolved Hide resolved

class UpdateDiscount implements \JsonSerializable
{
Expand All @@ -30,6 +31,7 @@ public function __construct(
public readonly array|Undefined|null $restrictTo = new Undefined(),
public readonly string|Undefined|null $expiresAt = new Undefined(),
public readonly DiscountStatus|Undefined $status = new Undefined(),
public readonly CustomData|Undefined|null $customData = new Undefined(),
) {
}

Expand All @@ -48,6 +50,7 @@ public function jsonSerialize(): array
'restrict_to' => $this->restrictTo,
'expires_at' => $this->expiresAt,
'status' => $this->status,
'custom_data' => $this->customData,
]);
}
}
Loading