PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / admin / modules / api / class-portal-api-controller.php

class-portal-api-controller.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at public/admin/modules/api/class-portal-api-controller.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadin\admin\api;
4
5 use Leadin\api\Base_Api_Controller;
6 use Leadin\admin\Connection;
7 use Leadin\data\Portal_Options;
8
9 /**
10 * Portal Api, used to clean portal id and domain from the WordPress options.
11 */
12 class Portal_Api_Controller extends Base_Api_Controller {
13
14 /**
15 * Class constructor, register route.
16 */
17 public function __construct() {
18 self::register_leadin_admin_route(
19 '/portal',
20 \WP_REST_Server::DELETABLE,
21 array( $this, 'disconnect_portal' )
22 );
23 self::register_leadin_admin_route(
24 '/business-unit',
25 \WP_REST_Server::READABLE,
26 array( $this, 'get_business_unit_option' )
27 );
28 self::register_leadin_admin_route(
29 '/business-unit',
30 \WP_REST_Server::EDITABLE,
31 array( $this, 'set_business_unit_option' )
32 );
33 }
34
35 /**
36 * Removes portal id and domain from the WordPress options.
37 */
38 public function disconnect_portal() {
39 if ( Connection::is_connected() ) {
40 Connection::disconnect();
41 return new \WP_REST_Response( 'OK', 200 );
42 }
43 return new \WP_REST_Response( 'No leadin_portal_id found, cannot disconnect', 400 );
44 }
45
46 /**
47 * Get business unit id option.
48 *
49 * @return string Business Unit Id
50 */
51 public function get_business_unit_option() {
52 return new \WP_REST_Response( Portal_Options::get_business_unit_id(), 200 );
53 }
54
55 /**
56 * Set business unit id option.
57 *
58 * @param number $request Request body.
59 *
60 * @return string OK response message.
61 */
62 public function set_business_unit_option( $request ) {
63 $data = json_decode( $request->get_body(), true );
64 $business_unit_id = $data['businessUnitId'];
65 Portal_Options::set_business_unit_id( $business_unit_id );
66 return new \WP_REST_Response( 'OK', 200 );
67 }
68
69 }
70