• File: GetSubscriptionCollectionParams.php
  • Full Path: /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/API/REST/V3/Routes/Subscriptions/Actions/GetSubscriptionCollectionParams.php
  • Date Modified: 09/10/2025 5:42 PM
  • File size: 2.07 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Give\API\REST\V3\Routes\Subscriptions\Actions;

use Give\Subscriptions\ValueObjects\SubscriptionStatus;

/**
 * @since 4.8.0
 */
class GetSubscriptionCollectionParams
{
    /**
     * @since 4.8.0
     */
    public function __invoke(): array
    {
        return [
            'sort' => [
                'description' => esc_html__('Sort field for subscription results', 'give'),
                'type' => 'string',
                'default' => 'id',
                'enum' => [
                    'id',
                    'createdAt',
                    'renewsAt',
                    'status',
                    'amount',
                    'feeAmountRecovered',
                    'donorId',
                    'firstName',
                    'lastName',
                ],
            ],
            'direction' => [
                'description' => esc_html__('Sort direction for subscription results', 'give'),
                'type' => 'string',
                'default' => 'DESC',
                'enum' => ['ASC', 'DESC'],
            ],
            'mode' => [
                'description' => esc_html__('Subscription mode (live or test)', 'give'),
                'type' => 'string',
                'default' => 'live',
                'enum' => ['live', 'test'],
            ],
            'status' => [
                'description' => esc_html__('Filter subscriptions by status', 'give'),
                'type' => 'array',
                'items' => [
                    'type' => 'string',
                    'enum' => ['any', ...array_values(SubscriptionStatus::toArray())],
                ],
                'default' => ['any'],
            ],
            'campaignId' => [
                'description' => esc_html__('Filter subscriptions by campaign ID', 'give'),
                'type' => 'integer',
                'default' => 0,
            ],
            'donorId' => [
                'description' => esc_html__('Filter subscriptions by donor ID', 'give'),
                'type' => 'integer',
                'default' => 0,
            ],
        ];
    }
}