<?php
/**
 * Receipt Order reference model.
 *
 * @package northmill-online-shared
 */

declare(strict_types=1);

namespace Northmill_Online_Shared\Abstracts\Hub_API\Models\Receipts;

use JsonSerializable;

/**
 * Class Order_Reference_Model
 */
class Receipt_Order_Reference_Model implements JsonSerializable {
	/**
	 * Index of this order reference.
	 *
	 * @var int
	 */
	protected int $Index = 0;

	/**
	 * Order number as in Hub.
	 *
	 * @var string
	 */
	protected string $OrderNumber;

	/**
	 * Origin of the order.
	 *
	 * @var string
	 */
	protected string $Origin = 'AppsOrder';

	/**
	 * Order change state.
	 *
	 * @var string|null
	 */
	protected ?string $OrderChangeState = null;

	/**
	 * Constructor.
	 *
	 * @param int         $index               Order reference index. Increments for each order reference.
	 * @param string      $order_number        Order number as in Hub.
	 * @param string|null $order_change_state  Order change state.
	 * @param string      $origin              Origin of the order.
	 */
	public function __construct(
		int $index,
		string $order_number,
		?string $order_change_state,
		string $origin,
	) {
		$this->Index            = $index;
		$this->OrderNumber      = $order_number;
		$this->OrderChangeState = $order_change_state;
		$this->Origin           = $origin;
	}

	/**
	 * {@inheritdoc}
	 */
	public function jsonSerialize(): array {
		return array(
			'Index'            => $this->Index,
			'OrderNumber'      => $this->OrderNumber,
			'Origin'           => $this->Origin,
			'OrderChangeState' => $this->OrderChangeState,
		);
	}
}
