-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathConnectionController.php
74 lines (66 loc) · 1.69 KB
/
ConnectionController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\BaseController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\TransportMethods;
defined( 'ABSPATH' ) || exit;
/**
* Class ConnectionController
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter
*/
class ConnectionController extends BaseController {
/**
* Register rest routes with WordPress.
*/
public function register_routes(): void {
$this->register_route(
'mc/connect',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connect_callback(),
'permission_callback' => $this->get_permission_callback(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
}
/**
* Get the callback function for the connection request.
*
* @return callable
*/
protected function get_connect_callback(): callable {
return function() {
return [
'url' => 'example.com',
];
};
}
/**
* Get the schema for settings endpoints.
*
* @return array
*/
protected function get_schema_properties(): array {
return [
'url' => [
'description' => __( 'Action that should be completed after connection.', 'google-listings-and-ads' ),
'type' => 'string',
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
];
}
/**
* Get the item schema name for the controller.
*
* Used for building the API response schema.
*
* @return string
*/
protected function get_schema_title(): string {
return 'merchant_center_connection';
}
}