class-wc-rest-payments-capital-controller.php
1.31 KB
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
<?php
/**
* Class WC_REST_Payments_Capital_Controller
*
* @package WooCommerce\Payments\Admin
*/
defined( 'ABSPATH' ) || exit;
/**
* REST controller for Capital loans functionality.
*/
class WC_REST_Payments_Capital_Controller extends WC_Payments_REST_Controller {
/**
* Endpoint path.
*
* @var string
*/
protected $rest_base = 'payments/capital';
/**
* Configure REST API routes.
*/
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/active_loan_summary',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_active_loan_summary' ],
'permission_callback' => [ $this, 'check_permission' ],
]
);
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/loans',
[
'methods' => WP_REST_Server::READABLE,
'callback' => [ $this, 'get_loans' ],
'permission_callback' => [ $this, 'check_permission' ],
]
);
}
/**
* Retrieve the summary of the active Capital loan.
*/
public function get_active_loan_summary() {
return $this->forward_request( 'get_active_loan_summary', [] );
}
/**
* Retrieve all the past and present Capital loans.
*/
public function get_loans() {
return $this->forward_request( 'get_loans', [] );
}
}