Code Duplication    Length = 42-42 lines in 2 locations

includes/api/class-wc-rest-shipping-zone-methods-controller.php 1 location

@@ 28-69 (lines=42) @@
25
	/**
26
	 * Register the routes for Shipping Zone Methods.
27
	 */
28
	public function register_routes() {
29
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods', array(
30
			array(
31
				'methods'             => WP_REST_Server::READABLE,
32
				'callback'            => array( $this, 'get_items' ),
33
				'permission_callback' => array( $this, 'get_items_permissions_check' ),
34
			),
35
			array(
36
				'methods'             => WP_REST_Server::CREATABLE,
37
				'callback'            => array( $this, 'create_item' ),
38
				'permission_callback' => array( $this, 'create_item_permissions_check' ),
39
				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
40
			),
41
			'schema' => array( $this, 'get_public_item_schema' ),
42
		) );
43
44
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods/(?P<instance_id>[\d-]+)', array(
45
			array(
46
				'methods'             => WP_REST_Server::READABLE,
47
				'callback'            => array( $this, 'get_item' ),
48
				'permission_callback' => array( $this, 'get_items_permissions_check' ),
49
			),
50
			array(
51
				'methods'             => WP_REST_Server::EDITABLE,
52
				'callback'            => array( $this, 'update_item' ),
53
				'permission_callback' => array( $this, 'update_items_permissions_check' ),
54
				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
55
			),
56
			array(
57
				'methods'             => WP_REST_Server::DELETABLE,
58
				'callback'            => array( $this, 'delete_item' ),
59
				'permission_callback' => array( $this, 'delete_items_permissions_check' ),
60
				'args'                => array(
61
					'force' => array(
62
						'default'     => false,
63
						'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
64
					),
65
				),
66
			),
67
			'schema' => array( $this, 'get_public_item_schema' ),
68
		) );
69
	}
70
71
	/**
72
	 * Get a single Shipping Zone Method.

includes/api/class-wc-rest-shipping-zones-controller.php 1 location

@@ 28-69 (lines=42) @@
25
	/**
26
	 * Register the routes for Shipping Zones.
27
	 */
28
	public function register_routes() {
29
		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
30
			array(
31
				'methods'             => WP_REST_Server::READABLE,
32
				'callback'            => array( $this, 'get_items' ),
33
				'permission_callback' => array( $this, 'get_items_permissions_check' ),
34
			),
35
			array(
36
				'methods'             => WP_REST_Server::CREATABLE,
37
				'callback'            => array( $this, 'create_item' ),
38
				'permission_callback' => array( $this, 'create_item_permissions_check' ),
39
				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
40
			),
41
			'schema' => array( $this, 'get_public_item_schema' ),
42
		) );
43
44
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d-]+)', array(
45
			array(
46
				'methods'             => WP_REST_Server::READABLE,
47
				'callback'            => array( $this, 'get_item' ),
48
				'permission_callback' => array( $this, 'get_items_permissions_check' ),
49
			),
50
			array(
51
				'methods'             => WP_REST_Server::EDITABLE,
52
				'callback'            => array( $this, 'update_item' ),
53
				'permission_callback' => array( $this, 'update_items_permissions_check' ),
54
				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
55
			),
56
			array(
57
				'methods'             => WP_REST_Server::DELETABLE,
58
				'callback'            => array( $this, 'delete_item' ),
59
				'permission_callback' => array( $this, 'delete_items_permissions_check' ),
60
				'args'                => array(
61
					'force' => array(
62
						'default'     => false,
63
						'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ),
64
					),
65
				),
66
			),
67
			'schema' => array( $this, 'get_public_item_schema' ),
68
		) );
69
	}
70
71
	/**
72
	 * Get a single Shipping Zone.