<?php

namespace PostenBringCheckout\admin\bring\models\booking;

defined( 'ABSPATH' ) || exit;

class Parties {
	public Party $sender;
	public Party $recipient;
	public ?PickupPoint $pickupPoint;

	public function __construct( Party $sender, Party $recipient, ?PickupPoint $pickupPoint = null ) {
		$this->sender      = $sender;
		$this->recipient   = $recipient;
		$this->pickupPoint = $pickupPoint;
	}

	public function toArray(): array {
		$data = get_object_vars( $this );
		if ( $this->pickupPoint ) {
			$data['pickupPoint'] = $this->pickupPoint->toArray();
		}
		return $data;
	}
}
