PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.6.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.6.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Api / Routes / IntegrationsRoutes.php
hostinger-reach / src / Api / Routes Last commit date
FormsRoutes.php 9 months ago HostingRoutes.php 3 months ago IntegrationsRoutes.php 8 months ago ReachRoutes.php 1 month ago Routes.php 5 months ago
IntegrationsRoutes.php
106 lines
1 <?php
2
3 namespace Hostinger\Reach\Api\Routes;
4
5 use Hostinger\Reach\Api\Handlers\IntegrationsApiHandler;
6 use Hostinger\Reach\Integrations\Integration;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 die;
10 }
11
12 class IntegrationsRoutes extends Routes {
13
14 private IntegrationsApiHandler $handler;
15
16 public function __construct( IntegrationsApiHandler $handler ) {
17 $this->handler = $handler;
18 }
19
20 public function register_routes(): void {
21 register_rest_route(
22 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
23 'integrations',
24 array(
25 'methods' => 'GET',
26 'callback' => array( $this->handler, 'get_integrations_handler' ),
27 'permission_callback' => '__return_true',
28 )
29 );
30
31 register_rest_route(
32 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
33 'integrations',
34 array(
35 'methods' => 'POST',
36 'callback' => array( $this->handler, 'post_integrations_handler' ),
37 'permission_callback' => array( $this, 'permission_check' ),
38 'args' => array(
39 'integration' => array(
40 'required' => true,
41 'type' => 'string',
42 'validate_callback' => function ( $param ) {
43 return array_key_exists( $param, IntegrationsApiHandler::get_integrations() );
44 },
45 ),
46 Integration::INTEGRATION_IS_ACTIVE => array(
47 'required' => true,
48 'type' => 'boolean',
49 ),
50 ),
51 )
52 );
53
54 register_rest_route(
55 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
56 'import/(?P<integration>[a-z0-9-]+)',
57 array(
58 'methods' => 'GET',
59 'callback' => array( $this->handler, 'get_import_handler' ),
60 'permission_callback' => array( $this, 'permission_check' ),
61 'args' => array(
62 'integration' => array(
63 'required' => true,
64 'type' => 'string',
65 'validate_callback' => function ( $param ) {
66 return array_key_exists( $param, IntegrationsApiHandler::get_integrations() );
67 },
68 ),
69 ),
70 )
71 );
72
73 register_rest_route(
74 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
75 'import',
76 array(
77 'methods' => 'POST',
78 'callback' => array( $this->handler, 'post_import_handler' ),
79 'permission_callback' => array( $this, 'permission_check' ),
80 'args' => array(
81 'integrations' => array(
82 'required' => true,
83 'type' => 'object',
84 'validate_callback' => function ( $param ) {
85 foreach ( array_keys( $param ) as $integration ) {
86 if ( ! array_key_exists( $integration, IntegrationsApiHandler::get_integrations() ) ) {
87 return false;
88 }
89 }
90
91 // Validate if the value structure is an array.
92 foreach ( $param as $ids ) {
93 if ( ! is_array( $ids ) ) {
94 return false;
95 }
96 }
97
98 return true;
99 },
100 ),
101 ),
102 )
103 );
104 }
105 }
106