1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace WC_POS\API;
13
14 use WC_API_Resource;
15 use WC_API_Server;
16
17 class Payload extends WC_API_Resource {
18
19 protected $base = '/pos';
20
21 22 23 24 25 26 27 28
29 public function register_routes( array $routes ) {
30
31
32 $routes[ $this->base ] = array(
33 array( array( $this, 'get_payload' ), WC_API_Server::READABLE )
34 );
35
36 return $routes;
37
38 }
39
40
41 42 43 44
45 public function get_payload( $wc_pos_admin = null ) {
46 $wc_api = WC()->api;
47
48 $payload = array(
49 'i18n' => $wc_api->{'\WC_POS\API\i18n'}->get_translations( $wc_pos_admin ),
50 'params' => $wc_api->{'\WC_POS\API\Params'}->get_params( $wc_pos_admin ),
51 'templates' => $wc_api->{'\WC_POS\API\Templates'}->get_templates( $wc_pos_admin ),
52 );
53
54 if( $wc_pos_admin ){
55 $payload['params']['settings'] = $wc_api->{'\WC_POS\API\Settings'}->get_settings( '', $wc_pos_admin );
56 } else {
57 $payload['params']['gateways'] = $wc_api->{'\WC_POS\API\Gateways'}->get_gateways();
58 }
59
60 return $payload;
61 }
62
63 }