PluginProbe
Packeta / 2.3.1
Packeta v2.3.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Core / Api / Rest / PickupPointValidateRequest.php

PickupPointValidateRequest.php in Packeta 2.3.1, at src/Packetery/Core/Api/Rest/PickupPointValidateRequest.php

90 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare( strict_types=1 );
4
5 namespace Packetery\Core\Api\Rest;
6
7 use Packetery\Core\Entity\Carrier;
8
9 class PickupPointValidateRequest {
10
11 /** @var array<string, bool|float|list<array<string, mixed>>|string|null> */
12 private $options;
13
14 /** @var array<string, string|null> */
15 private $point;
16
17 /**
18 * @param string $pickupPointId
19 * @param string|null $carrierId
20 * @param string|null $carrierPickupPointId
21 * @param string|null $country
22 * @param bool|null $claimAssistant
23 * @param bool|null $packetConsignment
24 * @param float|null $weight
25 * @param bool|null $livePickupPoint
26 * @param string|null $expeditionDay
27 * @param bool|null $cashOnDelivery
28 * @param array<string, float>|null $maxProductDimensions
29 * @param string[]|null $vendorGroups
30 */
31 public function __construct(
32 string $pickupPointId,
33 ?string $carrierId,
34 ?string $carrierPickupPointId,
35 ?string $country,
36 ?bool $claimAssistant,
37 ?bool $packetConsignment,
38 ?float $weight,
39 ?bool $livePickupPoint,
40 ?string $expeditionDay,
41 ?bool $cashOnDelivery,
42 ?array $maxProductDimensions,
43 ?array $vendorGroups
44 ) {
45 $resolvedCarrierId = is_numeric( $carrierId ) ? $carrierId : Carrier::INTERNAL_PICKUP_POINTS_ID;
46
47 $this->options = [
48 'country' => $country,
49 'carriers' => $resolvedCarrierId,
50 'claimAssistant' => $claimAssistant,
51 'packetConsignment' => $packetConsignment,
52 'weight' => $weight,
53 'livePickupPoint' => $livePickupPoint,
54 'expeditionDay' => $expeditionDay,
55 'cashOnDelivery' => $cashOnDelivery,
56 ];
57 if ( $resolvedCarrierId === Carrier::INTERNAL_PICKUP_POINTS_ID && $vendorGroups !== null ) {
58 $this->options['vendors'] = [];
59 foreach ( $vendorGroups as $vendorGroup ) {
60 $vendorOptions = [
61 'carrierId' => null,
62 'country' => $country,
63 ];
64 if ( $vendorGroup !== Carrier::VENDOR_GROUP_ZPOINT ) {
65 $vendorOptions['group'] = $vendorGroup;
66 }
67 $this->options['vendors'][] = $vendorOptions;
68 }
69 }
70 if ( $maxProductDimensions !== null ) {
71 $this->options['length'] = $maxProductDimensions['length'];
72 $this->options['width'] = $maxProductDimensions['width'];
73 $this->options['depth'] = $maxProductDimensions['depth'];
74 }
75
76 $this->point = [
77 'id' => $carrierPickupPointId === null ? $pickupPointId : null,
78 'carrierId' => is_numeric( $carrierId ) ? $carrierId : null,
79 'carrierPickupPointId' => $carrierPickupPointId,
80 ];
81 }
82
83 /**
84 * @return array<string, string|bool|float|null>
85 */
86 public function getSubmittableData(): array {
87 return array_filter( get_object_vars( $this ) );
88 }
89 }
90