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 all commits
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
3 changes: 3 additions & 0 deletions src/Entities/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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;

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
3 changes: 3 additions & 0 deletions src/Resources/Discounts/Operations/CreateDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\FiltersUndefined;
use Paddle\SDK\Undefined;

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,
]);
}
}
3 changes: 3 additions & 0 deletions src/Resources/Discounts/Operations/UpdateDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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\FiltersUndefined;
use Paddle\SDK\Undefined;

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