<?php

namespace PostenBringCheckout\admin\bring\models\booking;

defined( 'ABSPATH' ) || exit;

class MybringBookingRequest {
	public bool $testIndicator;
	public array $consignments;
	public int $schemaVersion;

	public function __construct( bool $testIndicator = false, array $consignments = array(), int $schemaVersion = 1 ) {
		$this->testIndicator = $testIndicator;
		$this->consignments  = $consignments;
		$this->schemaVersion = $schemaVersion;
	}

	public function toArray() {
		$data                 = get_object_vars( $this );
		$data['consignments'] = array_map(
			function ( $consignment ) {
				return $consignment->toArray();
			},
			$this->consignments
		);
		return $data;
	}
}
