<?php

namespace PostenBringCheckout\admin\api\models;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class OrderRequest {
	public string $order_ref;
	public bool $test_indicator;
	public string $selected_shipping_option;
	public string $customer_number;
	public array $packages;

	public function __construct( array $data ) {
		$this->order_ref                = $data['orderRef'];
		$this->test_indicator           = $data['testIndicator'];
		$this->selected_shipping_option = $data['selectedShippingOption'];
		$this->customer_number          = $data['customerNumber'];
		$this->packages                 = array_map(
			function ( $packageData ) {
				return new OrderRequestPackage( $packageData );
			},
			$data['packages']
		);
	}
}
