PluginProbe
PostNL for WooCommerce / 5.9.12
PostNL for WooCommerce v5.9.12
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / src / Rest_API / Legacy / Label_Service.php

Label_Service.php in PostNL for WooCommerce 5.9.12, at src/Rest_API/Legacy/Label_Service.php

58 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Rest_API\Legacy\Label_Service file.
4 *
5 * @package PostNLWooCommerce\Rest_API\Legacy
6 */
7
8 namespace PostNLWooCommerce\Rest_API\Legacy;
9
10 use PostNLWooCommerce\Order\Base as Order_Base;
11 use PostNLWooCommerce\Rest_API\Contracts\Label_Service_Interface;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class Label_Service
19 *
20 * Legacy service wrapper for outbound shipping labels. Implements
21 * Label_Service_Interface by delegating to Order\Base::create_label_pipeline()
22 * (API request → check_label_and_barcode → put_label_content →
23 * maybe_merge_labels) so no label-generation logic is duplicated.
24 *
25 * @package PostNLWooCommerce\Rest_API\Legacy
26 */
27 class Label_Service extends Order_Base implements Label_Service_Interface {
28
29 /**
30 * No WP hooks are registered by this service class.
31 *
32 * Required by Order\Base but intentionally a no-op here.
33 */
34 public function init_hooks() {
35 // Intentionally empty — this service does not register WordPress hooks.
36 }
37
38 /**
39 * Create a PostNL shipping label and return the normalized label record.
40 *
41 * Delegates to Order\Base::create_label_pipeline() — not the public
42 * create_label() — because this service extends Order\Base and create_label()
43 * now routes through the factory; calling it here would recurse. The pipeline
44 * runs the full flow: API request → check_label_and_barcode →
45 * put_label_content → maybe_merge_labels. The returned array is ready to be
46 * stored as _postnl_order_metadata['labels'].
47 *
48 * @param array $post_data Context needed to build and send the label request.
49 *
50 * @return array Normalized label record keyed by label-type string.
51 *
52 * @throws \Exception If the API request fails or the label array is empty.
53 */
54 public function create( array $post_data ): array {
55 return $this->create_label_pipeline( $post_data );
56 }
57 }
58