give
/
vendor
/
vendor-prefixed
/
stellarwp
/
licensing-api-client
/
src
/
Requests
/
Entitlement
/
SwitchTier.php
SwitchTier.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Requests/Entitlement/SwitchTier.php
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Give\Vendors\LiquidWeb\LicensingApiClient\Requests\Entitlement; |
| 4 | |
| 5 | /** |
| 6 | * Represents a switch entitlement tier request payload. |
| 7 | * |
| 8 | * @phpstan-type MetadataValue string|int|float|bool|null|array<int, string|int|float|bool|null> |
| 9 | * @phpstan-type MetadataMap array<string, MetadataValue> |
| 10 | * @phpstan-type SwitchTierPayload array{ |
| 11 | * license_key: string, |
| 12 | * product_slug: string, |
| 13 | * from_tier: string, |
| 14 | * to_tier: string, |
| 15 | * site_limit?: int, |
| 16 | * expiration_date?: string, |
| 17 | * purchase_date?: string, |
| 18 | * grants?: MetadataMap, |
| 19 | * metadata?: MetadataMap |
| 20 | * } |
| 21 | */ |
| 22 | final class SwitchTier |
| 23 | { |
| 24 | public string $licenseKey; |
| 25 | |
| 26 | public string $productSlug; |
| 27 | |
| 28 | public string $fromTier; |
| 29 | |
| 30 | public string $toTier; |
| 31 | |
| 32 | public ?int $siteLimit; |
| 33 | |
| 34 | public ?string $expirationDate; |
| 35 | |
| 36 | public ?string $purchaseDate; |
| 37 | |
| 38 | /** |
| 39 | * @var MetadataMap|null |
| 40 | */ |
| 41 | public ?array $grants; |
| 42 | |
| 43 | /** |
| 44 | * @var MetadataMap|null |
| 45 | */ |
| 46 | public ?array $metadata; |
| 47 | |
| 48 | /** |
| 49 | * @param MetadataMap|null $grants |
| 50 | * @param MetadataMap|null $metadata |
| 51 | */ |
| 52 | public function __construct( |
| 53 | string $licenseKey, |
| 54 | string $productSlug, |
| 55 | string $fromTier, |
| 56 | string $toTier, |
| 57 | ?int $siteLimit = null, |
| 58 | ?string $expirationDate = null, |
| 59 | ?string $purchaseDate = null, |
| 60 | ?array $grants = null, |
| 61 | ?array $metadata = null |
| 62 | ) { |
| 63 | $this->licenseKey = $licenseKey; |
| 64 | $this->productSlug = $productSlug; |
| 65 | $this->fromTier = $fromTier; |
| 66 | $this->toTier = $toTier; |
| 67 | $this->siteLimit = $siteLimit; |
| 68 | $this->expirationDate = $expirationDate; |
| 69 | $this->purchaseDate = $purchaseDate; |
| 70 | $this->grants = $grants; |
| 71 | $this->metadata = $metadata; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @return SwitchTierPayload |
| 76 | */ |
| 77 | public function toArray(): array { |
| 78 | return array_filter([ |
| 79 | 'license_key' => $this->licenseKey, |
| 80 | 'product_slug' => $this->productSlug, |
| 81 | 'from_tier' => $this->fromTier, |
| 82 | 'to_tier' => $this->toTier, |
| 83 | 'site_limit' => $this->siteLimit, |
| 84 | 'expiration_date' => $this->expirationDate, |
| 85 | 'purchase_date' => $this->purchaseDate, |
| 86 | 'grants' => $this->grants, |
| 87 | 'metadata' => $this->metadata, |
| 88 | ], static fn ($value): bool => $value !== null); |
| 89 | } |
| 90 | } |
| 91 |