Skip to content

Commit

Permalink
Merge branch 'main' into fix/subscription-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeymike authored Feb 7, 2024
2 parents a7e3458 + 28675e4 commit d3f79fb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Entities/Event/EventTypeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
enum EventTypeName: string
{
case AddressCreated = 'address.created';
case AddressImported = 'address.imported';
case AddressUpdated = 'address.updated';
case AdjustmentCreated = 'adjustment.created';
case AdjustmentUpdated = 'adjustment.updated';
case BusinessCreated = 'business.created';
case BusinessImported = 'business.imported';
case BusinessUpdated = 'business.updated';
case CustomerCreated = 'customer.created';
case CustomerImported = 'customer.imported';
Expand Down
6 changes: 6 additions & 0 deletions src/Entities/Notification/NotificationDiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Paddle\SDK\Entities\Discount\DiscountType;
use Paddle\SDK\Entities\Entity;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\ImportMeta;

class NotificationDiscount implements Entity
{
Expand All @@ -35,6 +37,8 @@ protected function __construct(
public int|null $maximumRecurringIntervals,
public int|null $usageLimit,
public array|null $restrictTo,
public CustomData|null $customData,
public ImportMeta|null $importMeta,
public \DateTimeInterface|null $expiresAt,
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
Expand All @@ -56,6 +60,8 @@ public static function from(array $data): self
maximumRecurringIntervals: $data['maximum_recurring_intervals'],
usageLimit: $data['usage_limit'] ?? null,
restrictTo: $data['restrict_to'] ?? null,
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
expiresAt: isset($data['expires_at']) ? DateTime::from($data['expires_at']) : null,
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
Expand Down
5 changes: 4 additions & 1 deletion src/Entities/Notification/NotificationSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Paddle\SDK\Entities\Shared\CollectionMode;
use Paddle\SDK\Entities\Shared\CurrencyCode;
use Paddle\SDK\Entities\Shared\CustomData;
use Paddle\SDK\Entities\Shared\ImportMeta;
use Paddle\SDK\Entities\Shared\TimePeriod;
use Paddle\SDK\Entities\Subscription\SubscriptionDiscount;
use Paddle\SDK\Entities\Subscription\SubscriptionItem;
Expand Down Expand Up @@ -41,11 +42,12 @@ protected function __construct(
public SubscriptionDiscount|null $discount,
public CollectionMode $collectionMode,
public BillingDetails|null $billingDetails,
public SubscriptionTimePeriod $currentBillingPeriod,
public SubscriptionTimePeriod|null $currentBillingPeriod,
public TimePeriod $billingCycle,
public SubscriptionScheduledChange|null $scheduledChange,
public array $items,
public CustomData|null $customData,
public ImportMeta|null $importMeta,
) {
}

Expand Down Expand Up @@ -77,6 +79,7 @@ public static function from(array $data): self
: null,
items: array_map(fn (array $item): SubscriptionItem => SubscriptionItem::from($item), $data['items']),
customData: isset($data['custom_data']) ? new CustomData($data['custom_data']) : null,
importMeta: isset($data['import_meta']) ? ImportMeta::from($data['import_meta']) : null,
);
}
}
2 changes: 2 additions & 0 deletions src/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected function __construct(
public \DateTimeInterface $createdAt,
public \DateTimeInterface $updatedAt,
public \DateTimeInterface|null $billedAt,
public string|null $receiptData,
public Address|null $address,
public array $adjustments,
public TransactionAdjustmentsTotals|null $adjustmentsTotals,
Expand Down Expand Up @@ -94,6 +95,7 @@ public static function from(array $data): self
createdAt: DateTime::from($data['created_at']),
updatedAt: DateTime::from($data['updated_at']),
billedAt: isset($data['billed_at']) ? DateTime::from($data['billed_at']) : null,
receiptData: $data['receipt_data'] ?? null,
address: isset($data['address']) ? Address::from($data['address']) : null,
adjustments: array_map(fn (array $adjustment): TransactionAdjustment => TransactionAdjustment::from($adjustment), $data['adjustments'] ?? []),
adjustmentsTotals: isset($data['adjustments_totals']) ? TransactionAdjustmentsTotals::from($data['adjustments_totals']) : null,
Expand Down

0 comments on commit d3f79fb

Please sign in to comment.