give
/
src
/
API
/
REST
/
V3
/
Routes
/
Subscriptions
/
Actions
/
GetSubscriptionCollectionParams.php
GetSubscriptionCollectionParams.php
9 months ago
GetSubscriptionItemSchema.php
8 months ago
GetSubscriptionSharedParamsForGetMethods.php
9 months ago
GetSubscriptionCollectionParams.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\API\REST\V3\Routes\Subscriptions\Actions; |
| 4 | |
| 5 | use Give\Subscriptions\ValueObjects\SubscriptionStatus; |
| 6 | |
| 7 | /** |
| 8 | * @since 4.8.0 |
| 9 | */ |
| 10 | class GetSubscriptionCollectionParams |
| 11 | { |
| 12 | /** |
| 13 | * @since 4.8.0 |
| 14 | */ |
| 15 | public function __invoke(): array |
| 16 | { |
| 17 | return [ |
| 18 | 'sort' => [ |
| 19 | 'description' => esc_html__('Sort field for subscription results', 'give'), |
| 20 | 'type' => 'string', |
| 21 | 'default' => 'id', |
| 22 | 'enum' => [ |
| 23 | 'id', |
| 24 | 'createdAt', |
| 25 | 'renewsAt', |
| 26 | 'status', |
| 27 | 'amount', |
| 28 | 'feeAmountRecovered', |
| 29 | 'donorId', |
| 30 | 'firstName', |
| 31 | 'lastName', |
| 32 | ], |
| 33 | ], |
| 34 | 'direction' => [ |
| 35 | 'description' => esc_html__('Sort direction for subscription results', 'give'), |
| 36 | 'type' => 'string', |
| 37 | 'default' => 'DESC', |
| 38 | 'enum' => ['ASC', 'DESC'], |
| 39 | ], |
| 40 | 'mode' => [ |
| 41 | 'description' => esc_html__('Subscription mode (live or test)', 'give'), |
| 42 | 'type' => 'string', |
| 43 | 'default' => 'live', |
| 44 | 'enum' => ['live', 'test'], |
| 45 | ], |
| 46 | 'status' => [ |
| 47 | 'description' => esc_html__('Filter subscriptions by status', 'give'), |
| 48 | 'type' => 'array', |
| 49 | 'items' => [ |
| 50 | 'type' => 'string', |
| 51 | 'enum' => ['any', ...array_values(SubscriptionStatus::toArray())], |
| 52 | ], |
| 53 | 'default' => ['any'], |
| 54 | ], |
| 55 | 'campaignId' => [ |
| 56 | 'description' => esc_html__('Filter subscriptions by campaign ID', 'give'), |
| 57 | 'type' => 'integer', |
| 58 | 'default' => 0, |
| 59 | ], |
| 60 | 'donorId' => [ |
| 61 | 'description' => esc_html__('Filter subscriptions by donor ID', 'give'), |
| 62 | 'type' => 'integer', |
| 63 | 'default' => 0, |
| 64 | ], |
| 65 | ]; |
| 66 | } |
| 67 | } |
| 68 |