Exceptions
3 years ago
GlobalStyles.php
3 years ago
LegacyServiceProvider.php
2 years ago
Onboarding.php
3 years ago
PaymentGateways.php
3 years ago
RequestType.php
3 years ago
RestAPI.php
3 years ago
Routes.php
4 years ago
ServiceProvider.php
4 years ago
RestAPI.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\ServiceProviders; |
| 4 | |
| 5 | use Give\API\Endpoints\Logs\FlushLogs; |
| 6 | use Give\API\Endpoints\Logs\GetLogs; |
| 7 | use Give\API\Endpoints\Migrations\GetMigrations; |
| 8 | use Give\API\Endpoints\Migrations\RunMigration; |
| 9 | use Give\API\Endpoints\Reports\AverageDonation; |
| 10 | use Give\API\Endpoints\Reports\FormPerformance; |
| 11 | use Give\API\Endpoints\Reports\Income; |
| 12 | use Give\API\Endpoints\Reports\IncomeBreakdown; |
| 13 | use Give\API\Endpoints\Reports\PaymentMethods; |
| 14 | use Give\API\Endpoints\Reports\PaymentStatuses; |
| 15 | use Give\API\Endpoints\Reports\RecentDonations; |
| 16 | use Give\API\Endpoints\Reports\TopDonors; |
| 17 | use Give\API\Endpoints\Reports\TotalDonors; |
| 18 | use Give\API\Endpoints\Reports\TotalIncome; |
| 19 | use Give\API\Endpoints\Reports\TotalRefunds; |
| 20 | use Give\API\RestRoute; |
| 21 | use Give\DonationForms\V2\Endpoints\FormActions; |
| 22 | use Give\DonationForms\V2\Endpoints\ListDonationForms; |
| 23 | use Give\DonationForms\V2\Endpoints\SwitchDonationFormView; |
| 24 | use Give\Donations\Endpoints\DonationActions; |
| 25 | use Give\Donations\Endpoints\ListDonations; |
| 26 | use Give\Donations\Endpoints\SwitchDonationView; |
| 27 | use Give\Donors\Endpoints\DeleteDonor; |
| 28 | use Give\Donors\Endpoints\ListDonors; |
| 29 | use Give\Donors\Endpoints\SwitchDonorView; |
| 30 | use Give\Subscriptions\Endpoints\ListSubscriptions; |
| 31 | use Give\Subscriptions\Endpoints\SubscriptionActions; |
| 32 | use Give\Subscriptions\Endpoints\SwitchSubscriptionView; |
| 33 | |
| 34 | class RestAPI implements ServiceProvider |
| 35 | { |
| 36 | /** |
| 37 | * @var string[] array of RestRoute classes |
| 38 | */ |
| 39 | private $reportRoutes = [ |
| 40 | PaymentStatuses::class, |
| 41 | PaymentMethods::class, |
| 42 | FormPerformance::class, |
| 43 | TopDonors::class, |
| 44 | RecentDonations::class, |
| 45 | Income::class, |
| 46 | IncomeBreakdown::class, |
| 47 | AverageDonation::class, |
| 48 | TotalDonors::class, |
| 49 | TotalIncome::class, |
| 50 | TotalRefunds::class, |
| 51 | GetLogs::class, |
| 52 | FlushLogs::class, |
| 53 | ListDonationForms::class, |
| 54 | ListDonors::class, |
| 55 | ListDonations::class, |
| 56 | ListSubscriptions::class, |
| 57 | SwitchDonorView::class, |
| 58 | SwitchDonationView::class, |
| 59 | SwitchDonationFormView::class, |
| 60 | SwitchSubscriptionView::class, |
| 61 | DonationActions::class, |
| 62 | SubscriptionActions::class, |
| 63 | DeleteDonor::class, |
| 64 | FormActions::class, |
| 65 | GetMigrations::class, |
| 66 | RunMigration::class, |
| 67 | ]; |
| 68 | |
| 69 | /** |
| 70 | * @inheritDoc |
| 71 | */ |
| 72 | public function register() |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @inheritDoc |
| 78 | */ |
| 79 | public function boot() |
| 80 | { |
| 81 | add_action('rest_api_init', [$this, 'registerRoutes']); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Calls the route registrations within the WordPress REST API hook |
| 86 | * |
| 87 | * @since 2.8.0 |
| 88 | */ |
| 89 | public function registerRoutes() |
| 90 | { |
| 91 | foreach ($this->reportRoutes as $route) { |
| 92 | /** @var RestRoute $route */ |
| 93 | $route = give()->make($route); |
| 94 | |
| 95 | $route->registerRoute(); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 |