-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
data objects for strict typing request params
- Loading branch information
1 parent
4884c8c
commit ce2b2bc
Showing
8 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Data\Requests; | ||
|
||
use Spatie\LaravelData\Data; | ||
use Spatie\LaravelData\Optional; | ||
|
||
class BasketData extends Data | ||
{ | ||
public function __construct( | ||
public string $return_url, | ||
public string $complete_url, | ||
public array|Optional $custom, | ||
public string|Optional $first_name, | ||
public string|Optional $last_name, | ||
public string|Optional $email | ||
){} | ||
|
||
public function toArrayWithFilledProps(): array | ||
{ | ||
$array = $this->transform(); | ||
|
||
return array_filter($array, function ($array) { | ||
return ! is_null($array); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Data\Requests; | ||
|
||
use Spatie\LaravelData\Data; | ||
use Spatie\LaravelData\Optional; | ||
|
||
class ItemData extends Data | ||
{ | ||
public function __construct( | ||
public PackageData $package, | ||
public int|Optional $qty, | ||
public array|Optional $revenue_share, | ||
public SaleData|Optional $sale, | ||
){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Data\Requests; | ||
|
||
use Shimmer\LaravelTebexCheckout\Enums\PackageExpiryPeriod; | ||
use Shimmer\LaravelTebexCheckout\Enums\PackageType; | ||
use Spatie\LaravelData\Data; | ||
use Spatie\LaravelData\Optional; | ||
|
||
class PackageData extends Data | ||
{ | ||
public function __construct( | ||
public string $name, | ||
public float $price, | ||
public PackageExpiryPeriod|Optional $expiry_period, | ||
public int|Optional $expiry_length, | ||
public array|Optional $metadata, | ||
public int|Optional $qty, | ||
public PackageType $type, | ||
public array|Optional $revenue_share, | ||
){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Data\Requests; | ||
|
||
use Shimmer\LaravelTebexCheckout\Enums\SaleDiscountType; | ||
use Spatie\LaravelData\Data; | ||
|
||
class SaleData extends Data | ||
{ | ||
public function __construct( | ||
public string $name, | ||
public SaleDiscountType $discount_type, | ||
public float $amount, | ||
){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Enums; | ||
|
||
enum PackageExpiryPeriod: string | ||
{ | ||
case Day = 'day'; | ||
|
||
case Month = 'month'; | ||
|
||
case Year = 'year'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Enums; | ||
|
||
enum PackageType: string | ||
{ | ||
case Single = 'single'; | ||
|
||
case Subscription = 'subscription'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Shimmer\LaravelTebexCheckout\Enums; | ||
|
||
enum SaleDiscountType: string | ||
{ | ||
case Percentage = 'percentage'; | ||
|
||
case Amount = 'amount'; | ||
|
||
case basket = 'basket'; | ||
} |