PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
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 8 months ago HostingRoutes.php 3 months ago IntegrationsRoutes.php 2 weeks ago ReachRoutes.php 1 month ago Routes.php 5 months ago
IntegrationsRoutes.php
116 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' => array( $this, 'permission_check' ),
28 )
29 );
30
31 register_rest_route(
32 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
33 'status',
34 array(
35 'methods' => 'GET',
36 'callback' => array( $this->handler, 'get_status_handler' ),
37 'permission_callback' => '__return_true',
38 )
39 );
40
41 register_rest_route(
42 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
43 'integrations',
44 array(
45 'methods' => 'POST',
46 'callback' => array( $this->handler, 'post_integrations_handler' ),
47 'permission_callback' => array( $this, 'permission_check' ),
48 'args' => array(
49 'integration' => array(
50 'required' => true,
51 'type' => 'string',
52 'validate_callback' => function ( $param ) {
53 return array_key_exists( $param, IntegrationsApiHandler::get_integrations() );
54 },
55 ),
56 Integration::INTEGRATION_IS_ACTIVE => array(
57 'required' => true,
58 'type' => 'boolean',
59 ),
60 ),
61 )
62 );
63
64 register_rest_route(
65 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
66 'import/(?P<integration>[a-z0-9-]+)',
67 array(
68 'methods' => 'GET',
69 'callback' => array( $this->handler, 'get_import_handler' ),
70 'permission_callback' => array( $this, 'permission_check' ),
71 'args' => array(
72 'integration' => array(
73 'required' => true,
74 'type' => 'string',
75 'validate_callback' => function ( $param ) {
76 return array_key_exists( $param, IntegrationsApiHandler::get_integrations() );
77 },
78 ),
79 ),
80 )
81 );
82
83 register_rest_route(
84 HOSTINGER_REACH_PLUGIN_REST_API_BASE,
85 'import',
86 array(
87 'methods' => 'POST',
88 'callback' => array( $this->handler, 'post_import_handler' ),
89 'permission_callback' => array( $this, 'permission_check' ),
90 'args' => array(
91 'integrations' => array(
92 'required' => true,
93 'type' => 'object',
94 'validate_callback' => function ( $param ) {
95 foreach ( array_keys( $param ) as $integration ) {
96 if ( ! array_key_exists( $integration, IntegrationsApiHandler::get_integrations() ) ) {
97 return false;
98 }
99 }
100
101 // Validate if the value structure is an array.
102 foreach ( $param as $ids ) {
103 if ( ! is_array( $ids ) ) {
104 return false;
105 }
106 }
107
108 return true;
109 },
110 ),
111 ),
112 )
113 );
114 }
115 }
116