| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
-
- namespace App\Commerce\Shipping\EasyParcel;
-
- /**
- * One courier service EasyParcel offers for a parcel, with its price.
- */
- final readonly class Quote
- {
- public function __construct(
- public string $serviceId,
- public string $courier,
- public string $service,
- public ?string $logo,
- /** In sen. */
- public int $price,
- /** The courier comes to the merchant's pickup address. */
- public bool $pickup,
- /** The merchant takes the parcel to a counter. */
- public bool $dropoff,
- /** Such as "About 3 days", when EasyParcel says. */
- public ?string $delivery,
- /** Something the merchant must know, such as "Pickup needs at least 3 parcels". */
- public ?string $note = null,
- ) {}
-
- /**
- * @return array<string, mixed>
- */
- public function toArray(): array
- {
- return [
- 'service_id' => $this->serviceId,
- 'courier' => $this->courier,
- 'service' => $this->service,
- 'logo' => $this->logo,
- 'price' => $this->price / 100,
- 'pickup' => $this->pickup,
- 'dropoff' => $this->dropoff,
- 'delivery' => $this->delivery,
- 'note' => $this->note,
- ];
- }
- }
|